regex question

Darrell news at dorb.com
Thu Jan 20 22:13:31 EST 2000


import re

pat = re.compile (r'(?:\D|^)\d(?:\D|$)')
x = pat.search ("1")
print 'X:', `x`
y = pat.search ("12")
print 'Y:', `y`
z = pat.search ("the number 1, don't you know?")
print 'Z:', `z`

######### OUTPUT
X: <re.MatchObject instance at 7f75b0>
Y: None
Z: <re.MatchObject instance at 7f8500>

--
--Darrell





More information about the Python-list mailing list