match pattern

Ian Kelly ian.g.kelly at gmail.com
Mon Sep 20 15:15:30 EDT 2010


On Mon, Sep 20, 2010 at 12:58 PM, rudikk00 <rudikk99 at yahoo.com> wrote:

> Hi all,
>
> I remember perl has a match function =~/H/ --> which searches if there
> is "H" pattern in line. Is there a reasonable analog of it in python?
>

Yes, have a look at the re module in the standard library.

If all you're interested in is exact matches and not regular expressions,
you can also use the "in" operator:

if "H" in my_string:
    do_something()

Cheers,
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100920/51dcde1d/attachment-0001.html>


More information about the Python-list mailing list