Defining re pattern for matching list of numbers
jorma kala
jjkk73 at gmail.com
Fri Nov 6 11:04:37 EST 2009
Hi,
I'm trying to write a re pattern to match a list of one or more numbers,
each number is in the range of 1-15 value and the numbers are separated by
spaces (but there are no spaces at the beginning and end of the string). For
instance:
"3"
"1 14 8"
but not:
"22"
" 5 11"
I've come up with something like this
re.compile("^((([1-9])|(1[0-8]))( +(?=[1-9]))*)+$")
but I can't believe this has to be so complicated.
Does anyone know some simpler re pattern to match this kind of string
Many thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091106/6bda7744/attachment.html>
More information about the Python-list
mailing list