mdelpeix
mdelpeix

Reputation: 187

Regex return sucess if there is none of the keywords

I have three text file

File 1 : AAA BBB CCC DDD EEEE

File 2 : AAA BBB CCC DDD FFFF

File 3 : AAA BBB CCC DDD

I'm searching a regex that return sucess on "File 3" because it doesn't contain "EEEE" and "FFFF"

i trying this kind (whithout success), it match if suffix "EEEE" or "FFFF" is absent

(?!EEEE|FFFF)

I search more and i find the exact regex that match, I want to reverse this regex :

(.*?EEEE.*?|.*?FFFF.*?)

Any suggestions ? Thanks in advance for your help

Upvotes: 0

Views: 91

Answers (2)

mdelpeix
mdelpeix

Reputation: 187

I found a partial solution with Multiline option activated

^(?!.*EEEE.*|.*FFFF.*).*?$

Explanation :

^ : begin string

(?!) : Match if suffix is absent

.*EEEE.*|.*FFFF.* : the suffix excluded are selected from 2 alternatives any character EEEE or FFFF followed by any character

.*? : any character, any repetition as few as possible

$ : end line or string

Upvotes: 0

Hoopdady
Hoopdady

Reputation: 2356

I'm not sure what all your data looks like, but try ^((?!EEEE|FFFF).)*$

Upvotes: 0

Related Questions