Regular Exp

Harvey Thomas hst at empolis.co.uk
Fri Oct 31 03:45:21 EST 2003


afds wrote:
> 
> If I want to match $.58 in $.589922 How do I do it with 
> Regular Expressions?
> 
> >>> s=re.search("\$\.[0-9]{2}", "$.589922")
> >>> s.string
> '$.589922'
> and not
> '$.58' which i s what I want
> I think it has something to do with Greediness right?
> 

Your regular expression is fine, but s.string is just the string you passed to search.
What you want is s.group(0) which will be '$.58'.


_____________________________________________________________________
This message has been checked for all known viruses by the MessageLabs Virus Scanning Service.





More information about the Python-list mailing list