The case of the sneaky backslash - Regex
- by Shane Cusson
I'm missing something very obvious here, but I just cant see it.
I've got:
string input = @"999\abc.txt";
string pattern = @"\\(.*)";
string output = Regex.Match(input,pattern).ToString();
Console.WriteLine(output);
My result is:
\abc.txt
I don't want the slash and cant figure out why it's sneaking into the output. I tried flipping the pattern, and the slash winds up in the output again:
string pattern = @"^(.*)\\";
and get:
999\
Strange. The result is fine in Osherove's Regulator. Any thoughts?
Thanks.