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

Is /l{ 12 , }/ just as valid as /l{12,}/? #639

Closed
icefapper opened this Issue Jul 21, 2016 · 6 comments

Comments

Projects
None yet
2 participants
@icefapper

icefapper commented Jul 21, 2016

Hello
From what I understand from the spec, whitespace is significant in literals; which, to me, means
QuantifierPrefix :: { DecimalDigits , DecimalDigits } in RE's should accept /l{12,}/ but not /l{ 12 , }/; but that is not the behavior of Firefox, for example; it accepts either of the above.

Has the insignificance of whitespace in an RE quantifier been mentioned in the spec? Or is Firefox actually wrong?

@claudepache

This comment has been minimized.

Show comment
Hide comment
@claudepache

claudepache Jul 21, 2016

Contributor

Just tested in Firefox and Safari:

/^a{1, }$/.exec('a') // null
/^a{1, }$/.exec('a{1, }') // ["a{1, }"]

I.e., /^a{1, }$/ is treated the same way as /^a\{1, \}$/. That semantics is already specced in Annex B (hint: ExtendedPatternCharacter does not exclude { nor }).

Contributor

claudepache commented Jul 21, 2016

Just tested in Firefox and Safari:

/^a{1, }$/.exec('a') // null
/^a{1, }$/.exec('a{1, }') // ["a{1, }"]

I.e., /^a{1, }$/ is treated the same way as /^a\{1, \}$/. That semantics is already specced in Annex B (hint: ExtendedPatternCharacter does not exclude { nor }).

@icefapper

This comment has been minimized.

Show comment
Hide comment
@icefapper

icefapper Jul 21, 2016

@claudepache
Thanks for the hint! Looks like it is as you say.

icefapper commented Jul 21, 2016

@claudepache
Thanks for the hint! Looks like it is as you say.

@icefapper icefapper closed this Jul 21, 2016

@icefapper icefapper reopened this Jul 21, 2016

@icefapper

This comment has been minimized.

Show comment
Hide comment
@icefapper

icefapper Jul 21, 2016

@claudepache
Please correct me if I'm actually wrong: /a{1, }/ is treated like /a\{1, \}/ because {1, } fails to get parsed as an RE quantifier? I'm asking this because that is what I understand from:

[~U]ExtendedAtom Quantifier
[~U]ExtendedAtom

could I ask if I'm correct?

icefapper commented Jul 21, 2016

@claudepache
Please correct me if I'm actually wrong: /a{1, }/ is treated like /a\{1, \}/ because {1, } fails to get parsed as an RE quantifier? I'm asking this because that is what I understand from:

[~U]ExtendedAtom Quantifier
[~U]ExtendedAtom

could I ask if I'm correct?

@claudepache

This comment has been minimized.

Show comment
Hide comment
@claudepache

claudepache Jul 21, 2016

Contributor

@icefapper You're correct. Under the annex-B semantics, when parsing a RegExp pattern, the order under which the production alternatives are tried is significant.

Contributor

claudepache commented Jul 21, 2016

@icefapper You're correct. Under the annex-B semantics, when parsing a RegExp pattern, the order under which the production alternatives are tried is significant.

@icefapper

This comment has been minimized.

Show comment
Hide comment
@icefapper

icefapper Jul 21, 2016

@claudepache Thanks!
I will leave this issue at your disposal; please close it whenver you find it appropriate.

icefapper commented Jul 21, 2016

@claudepache Thanks!
I will leave this issue at your disposal; please close it whenver you find it appropriate.

@icefapper

This comment has been minimized.

Show comment
Hide comment
@icefapper

icefapper Jul 22, 2016

@claudepache Also for the record, Chrome accepts /[\w-e]/ even though I've not come across any matching production for it in the spec.

icefapper commented Jul 22, 2016

@claudepache Also for the record, Chrome accepts /[\w-e]/ even though I've not come across any matching production for it in the spec.

@icefapper icefapper closed this Jul 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment