Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: regular expression inverse match NOT match?

by virtuemart2 (Novice)
on Sep 25, 2013 at 06:00 UTC ( #1055614=note: print w/ replies, xml ) Need Help??


in reply to regular expression inverse match NOT match?

"But is there some reason you couldn't have answered this yourself... or at least satisfied yourself that your code does or does not work?"
Firstly, thx for reply. It not work because just something wrong with my logic. Now I know the correct syntax, should be !~ but not !=~
furthermore want to ask, if I got keyword

AB CDE #don't know number of space between AB CDE #5 space =~ /AB.....CDE/ AB CDE #7 space =~ /AB.......CDE/

If I do NOT know number of space between AB and CDE
what symbol should I use in this case? thank you!


Comment on Re: regular expression inverse match NOT match?
Download Code
Re^2: regular expression inverse match NOT match?
by Laurent_R (Vicar) on Sep 25, 2013 at 06:14 UTC

    You could use either of those:

    /AB +CDE/; # one or more spaces /AB\s+CDE/; # one or more spacing characters (incl. spaces, tabs, end +of line, etc.)
Re^2: regular expression inverse match NOT match?
by ikegami (Pope) on Sep 26, 2013 at 13:57 UTC

    If it's just spaces, then you can use

    /AB\s*CDE/

    But if they can be any characters except the sequence CDE, you can use

    /AB(?:(?!CDE).)*CDE/s

    (?:(?!PAT).)* is to PAT as [^CHAR]* is to CHAR.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2014-07-26 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls