Reputation: 63
I have problem with regex!
I want to change the filelink ""file:\\" to "file:\" but with this solution i can't because it kill all my other slashes.
"file:\\mail\attach\2015_02\random file name" This file link is in string variable.
Do you have any idea or other solution? Thx!
Upvotes: 1
Views: 276
Reputation: 26
If you must use regex
const string originalPath = @"file:\\mail\attach\2015_02\random file name";
var newPath = Regex.Replace(originalPath, @"file:\\{2}(.+)", @"file:\$1");
Console.WriteLine(newPath);
Try this DotNetFiddle
Upvotes: 0
Reputation: 4692
no need for regex:
fileLink = fileLink.Replace(@"file:\\",@"file:\");
and you are done
Upvotes: 6