main
黄海 2 years ago
parent 7934d40bea
commit 15c6b2e8fa

@ -4,10 +4,11 @@ import re
if __name__ == '__main__':
# 是否匹配指定的正则表达式
r = '(\w*)\(\d*元\/年\)\w*'
str = 'asdfsdf(123元/年)sdfsdf'
r = r'(\w*)(\w*元/年)\w*'
str = r'asdfsdf(123元/年)sdfsdf'
m = re.search(r, str)
if m:
print("yes")
print(m.group(1))
else:
print("no")

Loading…
Cancel
Save