I have a string with a path name eg. 'c:\microsoft\windows\shared'. I want to pass this string to a reg exp and get the string 'c:\microsoft\windows' back from it. How do I do this?
I got a good answer for this already. However the regexp that I was given doesn't work on the type of path that name that I'm using. The answer I got was :
String sourcestring = @"c:\microsoft\windows\shared";
String matchpattern = @"(.*)\\.*";
String replacementpattern = @"$1";
string bob = Regex.Replace(sourcestring, matchpattern, replacementpattern);
which does in fact return c:\microsoft\windows to bob.
however, the path I'm using is something like the following: c:\.....\siteview\18.104.22.168__9f4da00116c38ec5
I need to trim the final folder of the path using a reg exp.