the implementation of regular expressions in javascript #446
-
I would like to have the texts explaining the implementation of regular expressions in javascript.
the result is an array : [ "", "", "", "" ],
` N.-B: I asked on stackoverflow but I didn't get the answer I was looking for. [https://stackoverflow.com/questions/77047894/i-dont-understand-how-an-elementary-rational-expression-works] |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
We should be able to call this match a "zero-length substring match", for the case you given here, the regular expression is equivalent to The spec shows that the regular expressions in JavaScript is modelled after the regular expression facility in the Perl 5 programming language. I have never known perl before. But I think we could infer the rule from the perl's document, see: https://perldoc.perl.org/perlre#Repeated-Patterns-Matching-a-Zero-length-Substring
From the last two sentences I given here, it can be infered that when So, for the regular expression given here, it will match each zero-length substrings between characters, and it's count is 4. |
Beta Was this translation helpful? Give feedback.
-
What you want is here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match Even when the match result is empty, the |
Beta Was this translation helpful? Give feedback.
What you want is here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match
Even when the match result is empty, the
lastIndex
is still advanced by 1.