Regular expressions in Python

Fredrik Lundh effbot at telia.com
Sun Sep 3 09:50:05 EDT 2000


john wrote:
> 1)  In Perl, I can do something like
> 
>     if (/START(.+?)END/) {
>       use $1 here (value caught in (.+?))
>     }
> 
>     what is the equivalent of Perl's $1, $2, ... in Python.

    m = re.search("START(.+?)END", string)
    if m:
        print m.group(1)

for more info, see "match objects" section in the library
reference.

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->




More information about the Python-list mailing list