掌握正则表达式基础知识:R星校长第1关教程与re.findall()函数详解
@R星级校长

1级:正则表达式的基本知识
正则表达式是字符串操作的逻辑公式,它是使用预先定义的某些特定字符,并组合这些特定字符来形成“规则字符串”以滤除符合此规则的内容。
它可以简单地理解为:在功能强大的搜索工具中,正则表达式是您要搜索内容的条件表达式。
为了完成此级别的任务,您需要掌握:1。常规模块函数re.findall(),2。各种正则表达式元听物的含义。
可以在命令行窗口中练习以下示例。
re.findall()函数
功能:遍历整个字符串,您可以在其中获取所有匹配字符串,然后返回列表。
一般用法:
re.Findall(r'regular Expression','''to tox tods匹配')
练习童年的联系规则
import re
text = "0537-146987425,0537-299656897,The moment you think about giving up,think of the reason why you held on so long. Total umbrella for someone else if he, you’re just not for him in the rain.Never put your happiness in someone else’s hands.Sometimes you have to give up on someone in order to respect yourself. aaaa bbbbcc d dddddd"
print(re.findall