When the engine sees that it should try again because of the /g, it steps one character past where last it tried.This explains why the final . in BrowserUk’s solution is not strictly necessary
Indeed. The final '.' is not necessary with Perl's regex engine.
But many other regex libraries -- including some that claim to be Perl-compatible -- do not have this pragmatic deviation from the classical regular expression operation; hence it has become a habit with me to do this explicitly.
In reply to Re^2: Lookahead assertion
by BrowserUk
in thread Lookahead assertion
by talexb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |