firasdib / Regex101

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

update .NET " escaping verbiage in explanation panel #1976

Closed Yayroos closed 1 year ago

Yayroos commented 1 year ago

Using C#/.NET flavour, a regex string with a double quote in it unescaped gives an error that "An unescaped delimiter must be escaped; in most languages with a blackslash"

but escaping the quote with a backslash gives the error "This token has no special meaning and has this been rendered erroneous"

working-name commented 1 year ago

Hello @Yayroos,

You're right the message is a little confusing for .NET specifically, especially with going the raw string route.

To escape a " you just prefix it with another ", so: ""

Yayroos commented 1 year ago

Ok, but in C# the escape needed is a backslash, because the regex is just given in a string. "" just causes errors.

working-name commented 1 year ago

I believe it depends on the type of string you utilize. The site uses an @-string.

Please see #1968 and let me know what you think. Thank you!

Yayroos commented 1 year ago

Thanks for pointing me to that. I suppose it's clear at this point that I'm not super familiar with C#. I've inherited a legacy codebase that needs a lot of work and this isn't my language of choice. Probably not within scope of the site itself to explain the difference in types of strings but perhaps linking to an explainer page elsewhere would be useful?