在将正则表达式匹配应用于以下带数字的混合字符串时,它会冻结,或至少使用过多的时间。为什么会这样,如何解决?
import re
s = "3.141592653589793238462643383279502884197169399375105820974944592.no"
pattern = re.compile(r'^([0-9]+[,.]?)+$')
print(pattern.match(s)) # this code freezes
我已经在“ Python 3.7.3,[GCC 7.3.0] :: Anaconda,Inc.在linux上”和“ Python 2.7.15rc1 [GCC 7.3.0]在linux2上”上对此进行了测试