in reply to perlretut - Perl regular expressions tutorial curveball
"don't" =~ / .+? \b{wb} /x; # matches the whole string
The regex matches from the first character up to the first following word boundary (which is just after the "t") so it matches the entire word and since there is only one word, that's the entire string in this case. Without the \b{wb} it just matches non-greedily 1 or more characters which is just the first "d".
Who is going to attempt natural language processing with a couple of lines of Perl regex in 2025?
For a large corpus? Nobody. For one sentence? Probably me. :-P
Bear in mind also that this example has probably been in perlretut for many, many years.
🦛
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: perlretut - Perl regular expressions tutorial curveball
by choroba (Cardinal) on Apr 10, 2025 at 21:33 UTC |