in reply to ^N.*(?!00$)
Hmm. The OPs spec was to match a WORD that starts with N and doesn't end with 00. All of the solutions I've seen posted so far work on a PHRASE (to be fair, including a phrase that consists of one word...) Fine if there is only going to be a single word to match against, but to be more general, use something like:
/\bN(?!\w*00\b)\w*\b/
as in:
my $string = q/N553342 N455673 N55788 N44200 NZ31200 NZ3120A/; my @matches = $string =~ /\bN(?!\w*00\b)\w*\b/g; print join "\n", @matches;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: ^N.*(?!00$)
by ady (Deacon) on Jun 06, 2005 at 14:48 UTC |