1

So for example I'm trying to not match 'test'. I've tried [^t][^e][^s][^t]. It won't match it, but it also won't match if at least one of the characters match the notes in the same position.

Any idea how to get around this?

Just a note, this is POSIX version of regex, there are no look-aheads or look-behinds.

Also, to clarify, the word I want is between certain characters, i.e. for the string "sdkfjdlskj <dsfdjslj@example.com>" I am looking for everything between '<>'. The email part is easy, but not matching a certain word is quite boggling.

Carlo Arenas
  • 55
  • 1
  • 4
A. L
  • 11,695
  • 23
  • 85
  • 163

1 Answers1

3

The typical way to get past that is to put a test at each position in the word.

Compressed

([^t]+|(t([^e]|$)|te([^s]|$)|tes([^t]|$)))+

Formatted

 (                          # (1 start)
      [^t]+ 
   |  
      (                          # (2 start)
           t
           ( [^e] | $ )               # (3)
        |  te
           ( [^s] | $ )               # (4)
        |  tes
           ( [^t] | $ )               # (5)
      )                          # (2 end)
 )+                         # (1 end)