Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Can't match negated words.

by hv (Parson)
on Jun 24, 2004 at 14:00 UTC ( #369363=note: print w/replies, xml ) Need Help??


in reply to Re: Can't match negated words.
in thread Can't match negated words.

First, You haven't duplicated Abigail-II's expression correctly; if you do so, it will work correctly:

if ($line =~ /^(?:(?!throw).)*$/s) { debug ("Doesn't contain throw"); }

An alternative formulation, which I find slightly cleaner, is to recast it as a single negative lookahead:

if ($line =~ /^(?!.*?throw)/) { ... }

Hugo

Replies are listed 'Best First'.
Re^3: Can't match negated words.
by perlgags78 (Acolyte) on Jun 24, 2004 at 15:14 UTC

    hi Hugo, I see that you've a ? before the throw. What function has this? Is the '?' associated with the .* or the throw? Also I'm having hassle getting return characters to appear in my posts so they kinda look like one line posts. Any ideas? Thanks, Mark.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://369363]
help
Chatterbox?
[Lady_Aleena]: karlgoethebier, when I don't know what I am looking at, it makes it hard to figure things out.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2017-06-26 09:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (575 votes). Check out past polls.