需求:
获取字符串Do you like 12 or 34?中的12
方法:
1. Python
a. Global function
import re
match = re.search(r"\d+", subject)
if match:
result = match.group()
else:
result = ""
b. Compiled object
import re
reobj = re.compile(r"\d+")match = reobj.search(subject)
if match:
result = match.group()
else:
result = ""
2. Tcl
regexp -linestop {\d+} $subject result