Bill Brown bio photo

Bill Brown

A complicated man.

Twitter Github

If you normally do a Regex.Escape(string) in C# to get some text ready for use as a regular expression, be aware that a string like ^Lijit (+$ will be escaped like so ^Lijit\ \(+http://www\.lijit\.com/\)$ instead of ^Lijit\ \(\+http://www\.lijit\.com/\)$ as you would expect.

Using that "escaped" regular expression will result in an ArgumentException along the lines of parsing "^Lijit (+$" - Quantifier {x,y} following nothing. That message is virtually un-Google-able until now.

The .NET exception occurs, I think, because the parser just doesn't understand the unescaped quantifier being next to an escaped control character. I believe that the escaping misses it because it uses that same parser because the plus sign is definitely one of the characters that the Escape method can handle.