如何使用 Python 正则表达式查找数字中重复的数字?
下面的代码使用 Python 正则表达式在给定的字符串中查找重复的数字。
更多Python相关文章,请阅读:Python 教程
示例
import re
result = re.search(r'(\d)\1{3}','54222267890' )
print result.group()
输出
执行上述代码的输出结果为:
2222
下面的代码使用 Python 正则表达式在给定的字符串中查找重复的数字。
更多Python相关文章,请阅读:Python 教程
import re
result = re.search(r'(\d)\1{3}','54222267890' )
print result.group()
执行上述代码的输出结果为:
2222
极客教程