8000 Chapter: Regular expressions (`RegExp`) · Issue #34 · rauschma/exploring-js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Chapter: Regular expressions (RegExp) #34

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

Open
rauschma opened this issue Jan 2, 2019 · 10 comments
Open

Chapter: Regular expressions (RegExp) #34

rauschma opened this issue Jan 2, 2019 · 10 comments

Comments

@rauschma
Copy link
Owner
rauschma commented Jan 2, 2019

No description provided.

@VernonHawk
Copy link

39.1.2. Cloning and non-destructively modifying regular expressions
...
new RegExp(regExp : RegExp, flags = regExp.flags) [ES6]
regExp is cloned. If flags is provided then it determines the flags of the copy.

Probably should be isn't provided.

@rauschma
Copy link
Owner Author

No, “is” is correct: If you don’t provide flags then the copy has the same flags as the original.

@VernonHawk
Copy link

Oh, ok, I misunderstood the meaning of the sentence, sorry.

@anthemion-org
Copy link

I'm looking at section 40.3. According to MDN, the 'a' in dotall should be capitalized: dotAll. Testing with NodeJS 10.16.3 confirms this. Same problem in the print edition.

@vsemozhetbyt
Copy link
vsemozhetbyt commented Aug 17, 2020

40.3 Flags

/g (.global): fundamentally changes how the following methods work.

Maybe it is worth to add String.prototype.replace() to the list?

@vsemozhetbyt
Copy link

40.5.9 Other methods for working with regular expressions

Its first parameter of String.prototype.split() is either a string or a regular expression.

Seems a bit off. Maybe "The first parameter of..." or "Its first parameter is..."?

@vsemozhetbyt
Copy link

40.6.5 Summary: .global (/g) and .sticky (/y)

Two tables use one legend with "Column “#”" explanation, but the first table has "Calls" column header instead of "#".

@davidmaxwaterman
Copy link

https://exploringjs.com/impatient-js/ch_regexps.html#replace-replaceAll

The table heading has "RegExp w/o \g" (backslash) which should probably be '/g' as in other instances.

@rauschma
Copy link
Owner Author
rauschma commented Jan 2, 2022

@davidmaxwaterman True, thanks! Fixed in next release.

@leodeslf
Copy link
leodeslf commented Jul 2, 2022

Hi!

I'd like to mention something that's not wrong, but, I think can actually lead to a misunderstanding about the exec method from RegExp.

Under the title 43.6.4.1 Getting a match object for the first match, it says:

Without the flag /g, .exec() returns ...

Which suggests that with the flag /g, .exec() returns 6907 something else, but it's not the case (maybe it worked differently before, or maybe I'm missing something).

console.log(/(a+)b/.exec('ab aab'));
// --> [ 'ab', 'a', index: 0, input: 'ab aab', groups: undefined ]
console.log(/(a+)b/g.exec('ab aab'));
// --> [ 'ab', 'a', index: 0, input: 'ab aab', groups: undefined ]

Wouldn't it be better to say that .exec() "ignores" the flag /g?

Cheers!

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

No branches or pull requests

6 participants
0