希望删除下面示例文本中 {} 之间的“#”字符
示例文本:
\(C##nH##{##2##n##+##1}O\)
预期输出:\(C##nH##{2n+1}O\)
我尝试了什么?\{[#].*\}
^.+?(?=##\w##)##\K|##(?!$)
非常感谢您的帮助!
最佳答案
您可以使用以下模式:
(?:\{|(?<!^)\G)[^#\r\n]*\K#+(?=.*\})
..并用空字符串替换。Demo .
故障:
(?: # Beginning of a non-capturing group.
\{ # Matches the character '{' literally.
| # Alternation (OR).
(?<!^)\G # Asserts position at the end of the previous match.
) # End of the non-capturing group.
[^#\r\n]* # Matches zero or more characters other than '#' or line breaks.
\K # Resets the starting point of the match (only include what comes next).
#+ # Matches one or more '#' characters.
(?=.*\}) # A positive Lookahead to make sure the `}` character exists.
关于regex - 需要使用 Notepad++ RegEx 来查找和删除大括号之间的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62946749/