Fredrik Lundh fredrik at
Mon Mar 6 08:04:13 CET 2006

Rares Vernica wrote:

> Isn't the following code supposed to return ('1994')?
>  >>>'(\d{4})?', '4 1994').groups()
> (None,)

it's supposed to return the first thing that matches your pattern, which,
in this case, is the empty string at the beginning of the target string.

if you want to look for groups of four digits, remove the "?"


More information about the Python-list mailing list