如何使用正则表达式模式替换以下字符串
The result is {A or D} or {Ef or G}.
Run Code Online (Sandbox Code Playgroud)
至
The result is {AD} or {EfG}.
只需要_or_在括号中删除它.
用空字符串替换此模式:
(?<=\{[^}]*)\sor\s(?=[^{]*\})
Run Code Online (Sandbox Code Playgroud)
这使用.NET的lookbehinds,它可以是任意长度,以确保括号中包含"或".