【发布时间】:2021-10-22 23:17:00
【问题描述】:
我有一个包含很多行文本的文件,如下所示:
(文字)
发生这种情况的情况很多:
在 textfile1.txt 中:
logging.info(文本文本文本(文本文本)文本文本)
如果我使用:$ sed -i '/(/,/)/d' textfile
退货
'文本文本)'
还有很多这样的例子:
(文字
文字文字(文字文字)
文字文字)
我想删除第一个左括号 & 和它各自的右括号(包括两个括号)之间的所有内容。不管用什么方法,随便找。这可能吗?
我尝试编写自己的 python 脚本,但我什至没有远程接近。寻找不同的解决方案比修复我认为的损坏的程序更容易。
我看过其他一些帖子,例如:
Find text between Opening parenthesis closing [closed]
match opening parenthesis to the corresponding closing parenthesis
regex: parse opening closing parenthesis with other parenthesis in between
但是我对正则表达式真的很不好,他们都使用正则表达式,我不知道
【问题讨论】: