in reply to Re: RE question: Sentence with a minimum length
in thread RE question: Sentence with a minimum length
The reason is that the look-ahead is not limited to what the [\w\s]{49,}? matches. A small demonstration:
#!/usr/bin/perl use strict; use warnings; my $re = qr{^\s*(?=\w+\s+\w+)[\w\s]{49,}?\w}; my $str = ('x' x 65) . ' x'; if ($str =~ m/$re/) { print $&, $/; } __END__ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You see that match only includes a long word, not a sentence. There is a sentence present, but it's not matched.
Update: In Perl 6 you could use & like this:
regex short_word { \s* [ & \w+ \s+ \w+ & .**?{1..50} ] }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: RE question: Sentence with a minimum length
by salva (Canon) on Oct 06, 2008 at 11:01 UTC | |
by salva (Canon) on Oct 06, 2008 at 16:41 UTC |