这是我的问题:在一个包含逗号的文本变量中,我想仅删除位于两个字符串之间(实际上是[
和]
)的逗号。例如使用以下字符串:
input = "The sun shines, that's fine [not, for, everyone] and if it rains, it Will Be better."
output = "The sun shines, that's fine [not for everyone] and if it rains, it Will Be better."
我知道如何使用.replace
替换整个变量,但我无法对其中的一部分进行操作。网站上有一些相关主题,但我无法将它们应用于我的问题,例如:
sub
是一种很有用的技术,但在这种情况下显然是过度的。 - georg