reg exp help

Christopher T King squirrel at WPI.EDU
Tue Jul 27 16:39:08 EDT 2004


On 27 Jul 2004, James Keasley wrote:

> This snippet should do it.
> 
> $string =~ /(\d+)E(.*)/;
>     if (length($s) == $1){
> 	print "$1\n";
>     }

Uhh... what I think he means is:

import re

l,s = re.match(r'(\d+)E(.*)',string).groups()
if len(s) == int(l):
    print s




More information about the Python-list mailing list