firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.21k stars 198 forks source link

Pattern showing error for C# #2017

Closed FarhanRafi closed 1 year ago

FarhanRafi commented 1 year ago

Question

Can anybody help me to understand why \".+\" & *"."* these regex are showing pattern errors for C#? These regex are working fine in other sites & environments but showing pattern errors in the regex101 website. ""."" is working fine in regex101 site. But backslash as escape character isn't working

OnlineCop commented 1 year ago

Due to .NET's delimiters differing from typical /search/ or /search/replace/ notation, verbatim @"..." are used (see this article. This verbatim notation allows the \ escape character to be entered as you would typically find in other regex syntaxes/flavors, with \d or \w working the way you would expect.

But because of that, double quotes themselves are not \" but instead need to be "".