Javascript Regex: Match any series of letters, unless they match a specific sequence -


i want match sequence of letters, except if match specific, unwanted sequence.

so example, if sentence is:

this cat. 

and want include letters except sequence cat, how write in regex?

i've tried (?!cat)([a-z])+ matches c. need match entire cat , exclude that. i've tried \b word boundaries well, no success.

\b(?:(?!\bcat\b)[a-za-z])+\b 

try this.see demo.

https://regex101.com/r/iv6mp5/1


Comments