Power Grep and regular expressions

Discussion in 'Programming' started by Robinox, Mar 22, 2008.

  1. #1
    Hi!
    I need in text find "word" and replace it with "otherword", but only if "word" is not in h1 or h2 tag, or in a link. I use PowerGrep. Iwrote this regexp

    word[^<h1>.*word.*</h1>][^<h2>.*word.*</h2>][^<a .*word.*</a>]

    Problem is, if i want find and replace string "word" in text "word, nextword" this regexp find not "word" but "word, n" (string +3more letters)
    Can someone give me any advice, where any mistake is?
     
    Robinox, Mar 22, 2008 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's adding three more chars onto it because you're telling it to test 3 more chars with each of your square bracket tests (those are for selecting individual chars; they don't eliminate an entire section like that). I'm not completely sure what PowerGrep is but I'm going to assume it's still all basically the same as how the regular expressions work in PHP. As for how to fix this, I'm not quite sure. I have never completely found out how to test for an expression that does not have a specified subpattern. :(
     
    zerxer, Mar 22, 2008 IP