tommsen
tommsen

Reputation: 237

regex to find characters but exclude some words that have that characters

I'm trying to find all occurences of ue and replace it with ü, but not for occurences like tuell. Reason is that german words like Aktuell should not be Aktüll afterwards. I tried different approaches with lookahead and lookbehind but could not get it working. I used https://regex101.com/ to test the expression. focus is on finding via regex, replacing via PHP preg_replace is not an issue.

Upvotes: 1

Views: 35

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626932

You may use a (?!ll) negative lookbehind to make sure the next 2 chars are ll right after ue:

ue(?!ll)

See the regex demo

See more details about lookarounds here.

Upvotes: 0

Related Questions