Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: PCRE help with negative match

by 2teez (Priest)
on Aug 11, 2013 at 00:28 UTC ( #1048962=note: print w/ replies, xml ) Need Help??


in reply to PCRE help with negative match

like this:

for (qw( 9759-222-sdfgh1-001-aaa-1234-abc 8898-222-sdfgh1-001-aaa-1234-abc 1234-222-sdfgh1-001-aaa-1234-abc )){ print $_,$/ if!/^9/; }
NOTE: That this would only work if there are no other string that start with '9' in your dataset.
UPDATE:
Please also see perlrequick and perlre.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re: PCRE help with negative match
Download Code
Re^2: PCRE help with negative match
by Oolankaloophid (Initiate) on Aug 11, 2013 at 00:45 UTC
    There will be hundreds, Thanks though.

      There will be hundreds, Thanks though.

      Then you have to specify more precisely what is the rule for matching a line and not the other. The !/^9/ regex given by 2teez meets perfectly the incomplete requirement you gave: it does not match the first line and does match the two others. An example is always vary useful for comprehension and illustration, but it is not a substitute for a functional rule explaining exactly what you need. May be changing 2teez's general code to something more specific such as !/^9759/ will do the trick, but it might now be too specific, how shall we know if you don't tell us? Please detail your requirement.

      Just a side question: you mention PCRE in the title of your post. Perl is certainly not using PCRE, since PCRE is basically a library to make Perl's internal regexes available functionalities similar to Perl's internal regexes available to languages other than Perl. Does that mean that you are using another language? I personally don't particularly care, but if such is the case, it means that we can offer you only pure regexes, not Perl code snippets.

      Update: Following an Anonymous Monk's comment just below, slightly modified my sentence above in order not to give the impression that PCRE is identical to Perl's internal regexes, it has quite similar functionalities, but it is clearly not the same thing.

        PCRE The name is misleading, because PCRE and Perl each have capabilities not shared by the other.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1048962]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (16)
As of 2014-07-22 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (122 votes), past polls