Help at regular expresion!

Discussion in 'PHP' started by Ronaldo30, Apr 18, 2008.

  1. #1
    How can i search with: regular expresion mod_rewrite

    - any word which is at the begining of the row except the word "search"

    ^([A-Za-z0-9]+) - this is the regular expresion for any word from the begining, but i don't know how to exclude the word "search"

    I tryed : ^([A-Za-z0-9]+[^s][^e][^a][^r][^c][^h]) but is not good

    Thanks!
     
    Ronaldo30, Apr 18, 2008 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your attempt there matches any alphanumeric string at least 7 characters long where the last 6 are not s e a r c and h respectively.

    Look up "negative lookahead" - it does exactly what you want.

    ^(?!search)([a-zA-Z0-9]+)
     
    rodney88, Apr 20, 2008 IP
  3. Ronaldo30

    Ronaldo30 Peon

    Messages:
    36
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank for your idea, it is very useful.

    Have a nice day!
     
    Ronaldo30, Apr 20, 2008 IP