views:

98

answers:

1

Hi,

I would like to create a regular expression to match every word, whitespace, punctuation and special characters in a string except for specific keywords or phrases. Because I only can modify regex, not server code I have to use match instead of replace.

I have something like this so far: (?!(quick|brown|fox|the lazy))\b\w+ but it ignores white spaces and special characters in this tool

Thanks.

+1  A: 

Does this work for you (?!(quick|brown|fox|the lazy))(\b\w+|[^\w])?

Do you have any examples?

Diadistis
Thanks. Great, I think it is what I need. But if I have "the lazy" phrase then it just ignores "the" keyword but "lazy" is still there. I am using this example http://www.cuneytyilmaz.com/prog/jrx/
negative