Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Can't match negated words.

by Abigail-II (Bishop)
on Jun 24, 2004 at 15:19 UTC ( #369390=note: print w/replies, xml ) Need Help??

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

Regexes match from left to right. So, if you first say "match /*", and then say, "don't match throw", it's *not* going to exclude "/*"'s that are preceeded with "throw". In fact, you haven't given any requirements for what should preceed "/*".

Ignoring the fact that you don't specify what should happen on a line like this:

/* throw /*
you might want to use something like:
although that can probably be optimized (and the more you know about where you are going to match against, the more possibilities for optimizing there are).


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

    I'd like to match the first '/*' and check that there's no

    throw declared before it.

    I think it should look something like this?


    I can't really understand what the '.)*' means after the throw?

    You could explain it briefly could you? Thanks,


      I think it should look something like this?
      No, I think not, for exactly the reasons I stated. But if you're convinced you're right, by all means, use your regex. It's not my program after all.
      I can't really understand what the '.)*' means after the throw?
      It doesn't make any sense at all. It's like asking what the "nd wh" in your question means. A dot means "match any character", and a star means "match the preceeding unit one or more times", but the closing parenthesis is belongs to the matching opening one.

      However, if you don't understand the most basic regexp tokens, I urge you to first learn basic regexes, before continuing asking questions.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2016-10-23 20:35 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (302 votes). Check out past polls.