plpl
plpl

Reputation: 21

Regexp to select everything except the specified string

I want to write a regexp that selects everything except the given sequence.

  1. the sequence can be at the beginning of a word
  2. the sequence can be in the middle

I was able to write something like this: ((?!patt).)+

It works almost well, but it matches everything except the first letter. Example https://regex101.com/r/WkAo7U/1

text: "pattern noster pattern"
regexp: ((?!patt).)+
result: "attern noster attern"
wanted result: "ern noster ern"

Upvotes: 1

Views: 31

Answers (0)

Related Questions