المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Need Help in Regular Expression?



C# Programming
09-19-2009, 02:00 AM
Hi,

I have the following string and i will pass the filename and then i want to get the corresponding path...


string url = @" --------------Boundary-00=_BLD1cvEPKmuNkgPvUNY3 Content-Type: text/plain; charset=utf-8; name=footer.txt Content-Disposition: attachment; filename=\""footer.txt\"" Content-Transfer-Encoding: base64 G:\test\Attach\test\footer.txt --------------Boundary-00=_BLD1cvEPKmuNkgPvUNY3-- ";

Regex r = new Regex(@"[a-z]:\\([a-z1-9\.\s]+\\)+[a-z1-9\.\s]+\.\w",RegexOptions.IgnoreCase);

string regString = r.Match(url).ToString();


I am able to get the output as :
G:\test\Attach\test\footer.t

In the above url string there maybe a chance that there will be 2 or more attachment codes like the above in the same string. I want to get the path alone like G:\test\Attach\test\ by passing a filename along with extension.

I don't know how to do it? Can someone pls help me out.

Thanks,
Raja.