Skip to content
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

updates to EscapedChars.md #34

Merged
merged 2 commits into from
Jul 6, 2015
Merged

updates to EscapedChars.md #34

merged 2 commits into from
Jul 6, 2015

Conversation

bergus
Copy link
Contributor

@bergus bergus commented Jul 5, 2015

as suggested in #31

bergus added 2 commits July 6, 2015 01:14
fixing some mistakes and typos; elabortating some cases
@bergus
Copy link
Contributor Author

bergus commented Jul 6, 2015

Uh, wait, is the following behaviour (tested in my browser console) actually buggy?

>>> new RegExp("\\u41" + "B").test("u41B")
false
>>> new RegExp("\\u41" + "B").test("\u041B")
true

If I append a non-hexadecimal character, it matches the literal letters (and treats \u as an IdentityEscape):

>>> new RegExp("\\u41" + "B%").test("u41B%")
true
>>> new RegExp("\\u41" + "B%").test("\u041B%")
false

@domenic
Copy link
Member

domenic commented Jul 6, 2015

Chrome has some bugs in this area, so definitely test a few browsers.

@bergus
Copy link
Contributor Author

bergus commented Jul 6, 2015

The test above was in (old) Opera. But before testing browsers, I wanted to get a confirmation that I've correctly understood the spec and the first snippet demonstrates a bug?

@anba
Copy link

anba commented Jul 6, 2015

But before testing browsers, I wanted to get a confirmation that I've correctly understood the spec and the first snippet demonstrates a bug?

The first snippet should give the following output (*):

js> new RegExp("\\u41" + "B").test("u41B")
true
js> new RegExp("\\u41" + "B").test("\u041B")
false

For Unicode enabled RegExps (or implementations without support for extension "B.1.4 Regular Expressions Patterns"), new RegExp("\\u41" + "B") throws a SyntaxError.

(*): Also tested in Edge, V8, JavaScriptCore, Nashorn and SpiderMonkey

benjamingr added a commit that referenced this pull request Jul 6, 2015
Escape hex characters in order to preserve unicode literals.
@benjamingr benjamingr merged commit b65a165 into tc39:master Jul 6, 2015
@benjamingr
Copy link
Collaborator

Thanks @bergus !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants