another newbie question - regex
Moshe Zadka
moshez at zadka.site.co.il
Mon Dec 25 09:34:44 EST 2000
On 25 Dec 2000, jp at ulgo.koti.com.pl (Jacek) wrote:
> "." - matches any character
> "*" - is 0 or more repetition
>
> so ".*" - matches everything?
Yep. And that's the common idiom for "everything too.".
> >>> print re.search(s,".*")
> None
> >>> print re.match(s,".*")
> None
Try
re.search(".*", s)
re.match(".*", s)
Your arguments were backwards.
In general, using re.compile will generate code that is (usually) both
clearer and faster.
everything = re.compile(".*")
everything.search(s)
everything.match(s)
More information about the Python-list
mailing list