Closed ZStoner closed 11 months ago
@ZStoner: POSIX-notation character classes, such as [[:punct:]]
, are not valid in .NET (at least according to regex101 when the .NET flavor is selected): https://regex101.com/r/DJjPfN/1
The Code Generator is expected to do a minimal amount of changes:
.NET stores regex PATTERNs in "quoted strings", so regex101 uses quotes for its delimiters.
@"..."
, @"""..."""
, @""""...""""
, @"""""..."""""
), regex101 uses these to avoid problems with things like multi-line patterns.Using string literals reduces the complexity of escaping special characters in C# strings, so most \
characters are written without conversion.
\
character in PATTERN or SUBSTITUTION is escaped as \\
.What you're seeing is an effect of using PCRE2
FLAVOR but with C#
LANGUAGE, where the delimiter isn't changed to one of C#'s "quoted string" types.
Bug Description
In the
C#
Code Generator, thepattern
string is using (/
Slashies/
) Regex syntax instead of (@"
Quoted"
) syntax. This is clearly a C# syntax error. The closest existing generator languages that create this syntax appear to bePHP
andRuby
.JavaScript
is similar but different.Reproduction steps
PCRE2
PCRE
,ECMAScript
,GoLang
Python
,Java
,.NET (C#)
,Rust
([[:punct:]]+)|(\w+)
any word character !!!
C#
Generated Code (C#):
C# Syntax Error:
Expected Outcome
The
pattern
variable should look something like this forC#
...Browser
Edge 119.0.2151.72
OS
Windows 11 22H2 (22621.2715)