kj <no.em...@please.post> writes:

> For a recovering Perl-head like me it is difficult to understand
> why Python's re module offers both match and search.  Why not just
> use search with a beginning-of-string anchor?

I need re.match when parsing the whole string.  In that case I never
want to search through the string, but process the whole string with
some regulat expression, for example when tokenizing.  For example:

    pos = 0
    while pos != len(s):
        match = TOKEN_RE.match(s, pos)
        if match:
            process_token(match)
            pos = match.end()
        else:
            raise ParseError('invalid syntax at position %d' % pos)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to