Regex problem

Andrew Dalke dalke at
Mon Oct 15 22:31:39 CEST 2001

Gustaf Liljegren:
>It works fine when
>>>> re.match(re_link, s1).group()
>look what happens as soon as I add a space (or any other character)
>What's wrong here? Matches shouldn't have to start from the beginning of a

Why not?  The documentation for 'match' says:
> If zero or more characters at the beginning of string match this
> regular expression, return a corresponding MatchObject instance.

You want the 'search' method.

You're not the only one who runs into this confusion.  Even though
I've been doing Python for years now, my old Perl habits still
want to call it "match" instead of "search".  That's documented too:

                    dalke at

More information about the Python-list mailing list