0
我想用正则表达式替换Python 3中的字符串。我需要将s1
中的字符串完全替换为空字符串。正则表达式替换Python 3中的字符串
s1 = "/* 123 */" # Pattern /* n */ where n can be any integer
s2 = re.sub(r'/*\s*\d+\s*/',"",s1)
print(s2)
输出(实际) - /* 123 */
#什么也没有发生
输出(预期) - BLANK