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
    Right, if the word was embedded in a phrase, your regex would do the job. As it is (and you couldn't know) I extract the words from a CSV file and have them in a $var which i match against a regex entered from the UI, so I don't really need "phrase generality" in this specific case.
    Good pt. of view, anyway :)
    -- allan