Hi,
I'm trying to remove the contents of a string matching the following regex: (\((?:[A-N]\d?(?:, )?)+\)).
The idea is to remove these allergen-notices from a string like this:
Frikadelle von Rind und Schwein (A, A1, C, I, J) mit Paprika-Zwiebelgemüse (J), dazu Spätzle (A, A1, C)
I tried the following:
let regex = Regex(#" (\((?:[A-N]\d?(?:, )?)+\))"#)
let title = oldTitle.replacingAll(matching: regex, with: "")
For some reason this leads to "Paprika-Zwiebelgemüse (J)" being turned into "Paprika-Zwiebelgemüs)" and not "Paprika-Zwiebelgemüse" as expected.
When I use the native String API (.replacingOccurrences(of: #" (\((?:[A-N]\d?(?:, )?)+\))"#, with: "", options: .regularExpression)), it works like it should.
Is this a bug in Regex or am I doing something wrong? This is on iOS in case that's relevant.
Thanks!
Hi,
I'm trying to remove the contents of a string matching the following regex:
(\((?:[A-N]\d?(?:, )?)+\)).The idea is to remove these allergen-notices from a string like this:
I tried the following:
For some reason this leads to "Paprika-Zwiebelgemüse (J)" being turned into "Paprika-Zwiebelgemüs)" and not "Paprika-Zwiebelgemüse" as expected.
When I use the native String API (
.replacingOccurrences(of: #" (\((?:[A-N]\d?(?:, )?)+\))"#, with: "", options: .regularExpression)), it works like it should.Is this a bug in Regex or am I doing something wrong? This is on iOS in case that's relevant.
Thanks!