0

I'm looking for a regular expression which matches the ä char but only when it isn't inside a double quote.

I was trying to solve this problem with a negative look behind that shouldn't have a double quote followed by any char which isn't a double quote, but actually only for even times, which means 1, 3, 5, etc

The attempt was something like this one: (?<!("[^"]*(?:(?:"[^"]*){2})*?)?)ä

But it doesn't work.

Or for a positive look behind for a double quote followed by any char which isn't a double quote but only for odd times, which means 0, 2, 4, etc

The attempt was something like this one: (?<=(?:(?:"[^"]*){2})*)ä

But it doesn't working either.

So all my attempts have failed! This is my test string:

This ä is to replace
"This ä is not to replace"
"This ä is not to replace" but this ä is to replace
This ä is to replace but "this ä is not to replace"
This ä is to replace, "this ä is not to replace", this ä is again to replace
"This ä is not to replace", "this ä neither", but this ä is to replace
"This ä and this ä aren't to replace", but this ä and this ä are to replace
This is the ultimate mix: ä ä "ä ä ä" ä ä ä "ä ä" "ä" "ä ä" ä ä ä
yaxebuhiy
  • 9
  • 2
  • Which programming language are you using? If it happens to be `PHP`, `Perl` or `Python`, you could use [**`"[^"]+"(*SKIP)(*FAIL)|ä`**](https://regex101.com/r/R3nBSi/1/), otherwise you'd need some programming logic. – Jan Mar 08 '18 at 11:21
  • This is a very common FAQ. The proposed duplicate is for commas but it should not be hard to see how to apply it to any other character equivalently. – tripleee Mar 08 '18 at 11:26

0 Answers0