You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::regex in C++ supports a modified ECMAScript syntax which differs from the actual ECMAScript regex syntax, causing compatibility issues with JavaScript-like patterns, notably in URL pattern matching.
I recommend keeping std::regex solution and on top of that using the regex engine proposal for others to properly support ecmascript regex through the plugin support.
std::regex in C++ supports a modified ECMAScript syntax which differs from the actual ECMAScript regex syntax, causing compatibility issues with JavaScript-like patterns, notably in URL pattern matching.
This problem arises in the tests of following PR: Node.js Pull Request #56452
The implementation of std::regex rejects certain regex constructs that are valid in JavaScript ECMAScript syntax:
Example Pattern:
"/([\\d&&[0-1]])"
Reproducible Example:
C++ Code to Simulate Failure:
The regex is somewhat confusing:
[[0-1]
is a character class made of three characters. Followed by]
.JavaScript handles this by interpreting the final ] as a literal character as if it does not close a valid character class.
C++ rejects the regex.
To achieve the intended regex behavior in C++, the pattern needs to be adjusted:
This discrepancy can lead to failures when C++ and JavaScript regex compatibility is assumed or required
The text was updated successfully, but these errors were encountered: