re.findall()-Problem ?

Bjorn Pettersen BPettersen at NAREX.com
Tue Oct 30 11:39:29 EST 2001


> From: Matthias Kuhn [mailto:Kuhn_Matthias at gmx.de] 
> 
> Hi,                                                   
>                                                       
> I have a question to re.findall(). In the sample-code below 
> there is a teststring 's', where I want to find some tokens, 
> preceding a number followed by a comma, e.g. '200,t'  ->  't'
> 
> The first re 'r1', finds the tokens 200 .. 241,
> in the second 'r2' I've added 250, so that it only finds
> the tokens in the first #BEGIN..#END-Block.
> 

[snip]

> r1 =
'(?s)200,(\S+).+?202,(\S+).+?210,(\S+).+?220,(\S+).+?240,(\S+).+?241,(\S
+)'
> r2 =
'(?s)200,(\S+).+?202,(\S+).+?210,(\S+).+?220,(\S+).+?240,(\S+).+?241,(\S
+).+?250,(\S+)'

I'm far from a regex guru, but isn't ".+?" equivalent to ".*"?

-- bjorn





More information about the Python-list mailing list