5,321
edits
Line 174: | Line 174: | ||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
import re | import re | ||
my_regex = re.compile(r'height:(\d+)cm') | |||
my_match = myReg.match("height:33cm"); | |||
print( | print(my_match[1]) | ||
# 33 | # 33 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
;Notes | ;Notes | ||
* <code>re.match</code> will return None if there is no match | * <code>re.match</code> will return None if there is no match |