DeusVult has asked for the wisdom of the Perl Monks concerning the following question:
Now that would match this:while (<>) { if ( /\w{5}\s\w{4}/ ) { print "This is a 5-letter word followed by a four-letter word\n"; } }
happy dude
but it would also match this:
man, that's a happy dude
Is there some way I can make the regex match ONLY 5-letter words followed by 4-letter words, but not ANYTHING else (so that it would match "happy dude" but NOT "man, that's a happy dude")? In other words, can I force the regex to say "the entire line being compared, not just a substring, has to match this pattern"?
Some people drink from the fountain of knowledge, others just gargle.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: "Complete match" regexes
by arhuman (Vicar) on Feb 02, 2001 at 20:18 UTC | |
by japhy (Canon) on Feb 02, 2001 at 20:42 UTC | |
by $code or die (Deacon) on Feb 02, 2001 at 20:47 UTC | |
Re: "Complete match" regexes
by azatoth (Curate) on Feb 02, 2001 at 20:37 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |