How to write this regular expression?

James Stroud jstroud at mbi.ucla.edu
Wed May 4 14:23:42 EDT 2005


Being one who types first and thinks later, I have to give this correction:

>>> r = re.compile(r"^_((\d)|([1-2]\d)|[3][0-1])(_(([4-9]\d+)|([3][1-9])|([1-9](\d){2,}))){,2}$")
>>> test(r)
_5 <type '_sre.SRE_Match'>
_10 <type '_sre.SRE_Match'>
_31 <type '_sre.SRE_Match'>
_1_50 <type '_sre.SRE_Match'>
_21_50_100 <type '_sre.SRE_Match'>
_500 <type 'NoneType'>
_21_10 <type 'NoneType'>
_21_50_40 <type '_sre.SRE_Match'>
_21_50_400 <type '_sre.SRE_Match'>
_21_50_1000 <type '_sre.SRE_Match'>
_5_40_100_50 <type 'NoneType'>
_3_5 <type 'NoneType'>
_43 <type 'NoneType'>
_5_43_69_98 <type 'NoneType'>


James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/



More information about the Python-list mailing list