It's not about \w, but about backtracking.
\w* initially 'eats' 2L, but then is forced to ... well... put the 'L' back on the table to let \S have it.
Hmm... maybe 'eating' is not the best image for what's going on with backtracking regexps...?
:)
| [reply] |
| [reply] [d/l] |
Precise definition depends on the language.
Mastering Regular Expressions, 2nd Ed., Jeffery E. F. Friedll, published by O'Reilly characterizes\w in its "Common Metacharacters..." chapter, this way:
Part-of_word character Often the same as [a-zA-Z0-9_], although some ools omit the underscore, while others include all the extraalphanumerics characters in the locale. If Unicode is supported, \w usually refers to all alphanumerics (notable exception: Sun's Java regex package whose \w is exactly [a-zA-Z0-9_</c>).
Regular Expressions Pocket Reference (also from O'Reilly) defines \w as:
- \p{IsWord} for Perl
- and as [A-Za-z0-9_] for Java.
Regretably, the definition of \p{isWord} -- [_\p{L1}\p{Lu}\p{Lt}\p{Lo}\p{Nd} -- is, for me, almost impenetrable but Friedll's characterization may be as good as you'll get without deep study of perlretut and friends.
| [reply] [d/l] [select] |
| [reply] [d/l] |