in reply to PCRE help with negative match

This works for your input data:
use warnings; use strict; use YAPE::Regex::Explain; while (<DATA>) { print if /(?<!9759)-222-\w/; }

Here's what your regex does: Tip #9 from the Basic debugging checklist: YAPE::Regex::Explain

use warnings; use strict; use YAPE::Regex::Explain; my $re = '(?<!9759-222)(\w\- {24})'; my $parser = YAPE::Regex::Explain->new($re); print $parser->explain(); __END__ The regular expression: (?-imsx:(?<!9759-222)(\w\- {24})) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- (?<! look behind to see if there is not: ---------------------------------------------------------------------- 9759-222 '9759-222' ---------------------------------------------------------------------- ) end of look-behind ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- \w word characters (a-z, A-Z, 0-9, _) ---------------------------------------------------------------------- \- '-' ---------------------------------------------------------------------- {24} ' ' (24 times) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

Replies are listed 'Best First'.
Re^2: PCRE help with negative match
by Oolankaloophid (Initiate) on Aug 11, 2013 at 00:46 UTC
    Giving it a shot now, thanks