6.01-re-split_chinese

时间:2022-07-25
本文章向大家介绍6.01-re-split_chinese,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
import re

# 1.拆分字符串
one = 'asdsfsgsh'

# 标准 是 s 为拆分

pattern = re.compile('s')
result = pattern.split(one)
# print(result)

# 2.匹配中文
two = '<a href="https://www.baidu.com/" nslog="normal" nslog-type="10600112" data-href="https://www.baidu.com/s?ie=utf-8&amp;fr=bks0000&amp;wd=">网页是最新版本的,适配移动端</a>'

# python中 匹配中问 [a-z] unicode的范围 * + ?
pattern = re.compile('[u4e00-u9fa5]+')

result = pattern.findall(two)
print(result)