-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regular expression parse error - /^\_/ and /\\{/g #69
Comments
The Ecmascript specification is quite strict in what escapes are allowed and required. In your case:
Most Ecmascript engines are rather loose about regexp syntax, accepting many regexps that are technically syntax errors in the specification (as far as I've been able to determine). Because this is common behavior, Duktape may need to move into that direction, but right now it follows the E5 specification quite strictly. |
@svaarala _ = > _( \ RegularExpressionNonTerminal ) /^\_/ is possible. |
Ecmascript specification defines RegExp syntax in Section 15.10.1: Ultimately it comes down to
The escaped character cannot be an identifier part, which includes a-z, A-Z, underscore, etc. |
IdentifierPart ::
IdentifierStart
UnicodeCombiningMark
UnicodeDigit
UnicodeConnectorPunctuation
<ZWNJ>
<ZWJ> Because of that '_' is IdentifierStart, Is Case1 invalid? |
Yes, IdentifierPart includes all IdentifierStart characters, e.g. underscore. The "realworld" label means that the desired behavior is not compliant but expected by users. |
@svaarala Thank you. :) |
I might be wrong in my interpretation of the RegExp syntax in E5 - but so far I haven't been informed otherwise :) |
@svaarala |
@svaarala |
No, as far as I understand V8 and other engines don't comply to the E5 specification - they have a wider regexp syntax. |
Underscore ('_') is not a special character and should not require escaping. |
Sorry, very well for '/a[0]/' |
You were missing the trailing trailing slash: |
@svaarala |
No problem :) Anyway, as I said, it's somewhat confusing that Ecmascript engines vary between what they accept and reject for regexps. |
@svaarala |
Since there's nothing to fix in this issue, I'll close this one. I added #74 to track all the known regexp "real world" issues so that there's a clear idea of what cases will at least need fixing. |
Hi, I have some tests for regular expression.
case 1
case 2
In the regular expression, I think that '' has some problem.
The text was updated successfully, but these errors were encountered: