matching exactly a 4 digit number in python

Mark Tolonen M8R-yfto6h at mailinator.com
Fri Nov 21 17:09:56 EST 2008


"harijay" <harijay at gmail.com> wrote in message 
news:7424ff80-c645-4b30-b963-67997be29108 at j38g2000yqa.googlegroups.com...
> I want to parse a number of strings and extract only those that
> contain a 4 digit number anywhere inside a string

Try:
    p = re.compile(r'\b\d{4}\b')

-Mark




More information about the Python-list mailing list