例如:你的订单是YT开头,后面一串数字的格式,那么下面的正则就是提取出文本中的所有订单号
import re
orderSnText="我的快递需要退货单号YT8763236797556,收到YT8763236797556回答"
pattern = r'YT\d+'
# 使用正则表达式
results = re.findall(pattern, orderSnText)
for result in results:
print(result)
例如:你的订单是YT开头,后面一串数字的格式,那么下面的正则就是提取出文本中的所有订单号
import re
orderSnText="我的快递需要退货单号YT8763236797556,收到YT8763236797556回答"
pattern = r'YT\d+'
# 使用正则表达式
results = re.findall(pattern, orderSnText)
for result in results:
print(result)