随笔分类 - 正则表达式
摘要:#encoding: utf-8 import re # 分组 text = "apple's price $99,orange's price is $10" ret = re.search('.*(\$\d+).*(\$\d+)',text) print(ret.group(0)) # ret.
阅读全文
摘要:#encoding: utf-8 import re text = "apple price is $299" ret = re.search("\$\d+",text) print(ret.group()) # r = raw = 原生的 # text = '\n' # print(text) t
阅读全文
摘要:import re # 1. 匹配某个字符串: text = "hello" ret = re.match('he',text) print(ret.group()) # 2. 点:匹配任意的字符 text = "\n" ret = re.match('.',text) print(ret.grou
阅读全文

浙公网安备 33010602011771号