Posted on 2003-12-10
I always think I understand regex's until I go to use them. I'm using C# and .NET Framework. Let's say I have the following string:
"C:\\MsDev\\Sharp\\bin\\Debug\\Control.dll`~`3`~`0`~`" notice that `~` is my delimiter
I want to extract the filename from the string using regex.
I think the following snippet should work, but it is assigning 'filename' with the entire string, not just the filename. Any ideas?? Thanks in advance.
//Get the filename from string using regex...
string filename = (Regex.Replace(dataString, "^(.*)(`~`)?", "$1")).ToString();