一个电话号码,如果区号为3位,那么区号后面的数字为8位;如果区号为4位,那么区号后面的数字为7位

In [1]: import re

In [2]: number = "020-232432354343234324"

In [3]: regular = re.compile(r'\d{4}-\d{7}|\d{3}-\d{8}')

In [4]: re.findall(regular, number)
Out[4]: ['020-23243235']

 

 

 

 

 

 

    

相关文章:

  • 2021-12-15
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-08-12
  • 2021-10-13
  • 2021-12-15
猜你喜欢
  • 2021-12-15
  • 2021-12-15
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案