Re: Testing for the first few letters of a string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jean-Paul Calderone

    Re: Testing for the first few letters of a string

    On Thu, 07 Aug 2008 23:08:10 +0200, magloca <magloca@mailin ater.comwrote:
    >John Machin wrote:
    >
    >>import re
    >>template = '^My name is alex'
    >>
    >The ^ is redundant.
    >
    >Didn't the OP want to match only at the beginning of the string?
    >
    That's why it's "redundant" instead of "incorrect" . ;)

    re.match = match(pattern, string, flags=0)
    Try to apply the pattern at the *start* of the string, returning
    a match object, or None if no match was found.

    Emphasis mine.

    Jean-Paul
Working...