我有这样的句子 -“this is a test. 4.55 and 5,000.” 我希望删除句子末尾的句点,但不是在数字之间。我的输出必须是 -“this is a test 4.55 and 5,000” 我尝试了以下选项,但没有得到所需的输出:
wordList = "this is a test. 4.55 and 5,000."
pattern3 = re.compile("[^\w\d]+")
wordList = pattern3.sub(' ',wordList)
我也尝试了以下两种方法:
pattern3 = re.compile("[^\w]|^[0-9]\.[0-9]")
pattern3 = re.compile("[^\w]|^([0-9]/.[0-9]+)")
我不知道哪里出了错,有人能给我一些指点吗?我查看了之前的帖子并尝试了它们,但对于我的情况它们并没有起作用。
\.$
(带有多行标志)呢? - Firas Dib