1.正则表达式中的操作符:

Python_正则表达式语法

 

 Python_正则表达式语法

 

2.re库的使用:

import re

#search方法要求只要待匹配的字符串中包含正则表达式中的字符串就可以
match = re.search('python+','1988 pythonnnn 2019')
print(match.group())

#match()方法要求待匹配的字符串开头必须要和正则表达式中的字符串一样
match = re.match('python+','pythonnnnn 2018')
print(match.group())

 

相关文章:

  • 2022-02-05
猜你喜欢
  • 2021-10-03
  • 2021-10-25
  • 2021-07-08
  • 2022-02-27
  • 2022-12-23
  • 2021-10-23
相关资源
相似解决方案