firasdib / Regex101

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

Input Regular Expression show invalid error when use '/' #1946

Closed GuilhermeBley closed 1 year ago

GuilhermeBley commented 1 year ago

Bug Description

Input Regular Expression show invalid error when use '/'

Reproduction steps

Put regular expression with '/' in a middle of the pattern

Ex: Pattern: [0-9]{9}-[0-9]{2}/[0-9]{4} This pattern thrown an error, but when i use C# (System.Text.RegularExpressions.Regex Version=4.0.0.0), this is success executed.

Expected Outcome

Don't show error "/ An unescaped delimiter must be escaped; in most languages with a backslash ()"

OS

Windows

Expression Link:

https://regex101.com/r/ji0RcR/1

working-name commented 1 year ago

Hi there!

The / is a delimiter which is the way the engine can tell where your regex expression begins and ends, and where the flags are or other such things. For the PCRE flavor which you have selected in your example link the / is the default delimiter. For .NET the delimiter is a ", which if you were to use in your expression you'd have to escape one way or another.

The error message on the right explains why it's a problem.

If you're writing expressions for C# I would recommend switching to that flavor to get these error messages if you happen to use something that's not supported by its regex engine.