Regular expression in javascript
2 answers
Expected behavior
The first read
is fixed as it follows ing
. Here ing
only matches. It is never included in the result.
Now we are in position after read
, i.e. are in i
.. here again ing
matches (because of \w*
) and gives an empty result because there is no between reading and ing.
You can use \w+(?=ing\b)
to avoid empty result
+7
source to share