I have strings in the following format
_AUTO_(123,SomeString)
and I am trying to extract 123 from the above string using regex. The regex, that I am using is:
const string pattern = @"\_AUTO\_\(?<number>(\d)+\,";
foreach(Match match in Regex.Matches(line, pattern)) {
Console.WriteLine(match.Groups["number"].Value);
}
I am getting Unrecognized escape sequence \_ error exception. Could someone please point me what I am doing wrong?
Thanks!
You don't need to escape the underscore (or, for that matter, the comma). Change your regex to:
@"_AUTO_\(?<number>(\d)+,"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With