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

Regular Expression Flags #81

Closed
Kikobeats opened this issue May 13, 2018 · 0 comments
Closed

Regular Expression Flags #81

Kikobeats opened this issue May 13, 2018 · 0 comments
Labels

Comments

@Kikobeats
Copy link
Owner

Kikobeats commented May 13, 2018

Unicode Flag (u)

The unicode flag was recently added:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode

It should be used by default!

/^.$/.test('a') //✅
/^.$/.test('🐶') //❌
/^.$/u.test('🐶') //✅

dot all flag (s)

By default, . matches any character except for line terminators:

/foo.bar/u.test('foo\nbar');
// → false
(It doesn’t match astral Unicode symbols either, but we fixed that by enabling the u flag.)

ES2018 introduces dotAll mode, enabled through the s flag. In dotAll mode, . matches line terminators as well.

/foo.bar/su.test('foo\nbar');
// → true

__

both flags can be used as the new standard

Reference:

@Kikobeats Kikobeats changed the title Unicode Flag Regular Expression Flags May 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant