如何使用正则表达式模式替换以下字符串

Sea*_* C. 2 c# regex string

如何使用正则表达式模式替换以下字符串

The result is {A or D} or {Ef or G}.
Run Code Online (Sandbox Code Playgroud)

The result is {AD} or {EfG}.

只需要_or_在括号中删除它.

Luc*_*ski 6

用空字符串替换此模式:

(?<=\{[^}]*)\sor\s(?=[^{]*\})
Run Code Online (Sandbox Code Playgroud)

这使用.NET的lookbehinds,它可以是任意长度,以确保括号中包含"或".