javascript-tutorial / en.javascript.info

Modern JavaScript Tutorial
https://javascript.info
Other
23.05k stars 3.82k forks source link

Add a solution that enables the direct use of atomic groups #3699

Open slevithan opened 1 month ago

slevithan commented 1 month ago

The catastrophic backtracking solution described where atomic groups are emulated using lookahead and backreferences is useful but can be tricky to use and error prone (e.g. when quantifying the result, or in longer patterns that rely on multiple atomic groups). So this adds a link to an easy to use solution that enables the direct use of atomic groups via (?>…) in native JS regexes.

CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.

slevithan commented 3 weeks ago

I updated the PR to make some additional tweaks: