string aniPattern=@"(?si:<option value=\\\"(?<year>.*?)\\)";
This breakes because the " in the middle. But I need that because I use it in a regex.
I tried to use string aniPattern="(?si:<option value=\\\"(?<year>.*?)\\\\)";
(without @) but it isnot a valid regex.
important - it isn't entirely clear what you want to match; I've answered on the premise that only the "
is being a problem - but see also Mike Caron's answer which assumes everything is escaped incorrectly.
With a verbatim string literal (i.e. @"..."
), "
is escaped to ""
- so your string becomes:
string aniPattern=@"(?si:<option value=\\\""(?<year>.*?)\\)";
With a regular string literal (without the leading @
), you would need a lot worse:
string aniPattern="(?si:<option value=\\\\\\\"(?<year>.*?)\\\\)";
string aniPattern=@"(?si:<option value=""(?<year>.*?)\)";
For @ escaped strings, you double the quotation mark to escape it, since backslash is not used.
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