[twill] Finding Multiple Instances of a String on a Page

Titus Brown titus at caltech.edu
Fri Feb 17 13:56:57 PST 2006

On Fri, Feb 17, 2006 at 03:23:26PM -0600, Terry Peppers wrote:
-> I just started playing around with twill and I really like it so far. I had
-> a question about the find command. The docs say the following:
-> *find* *<regexp>* -- assert that the page contains this regular expression.
-> The variable __match__ is set to the matching string.
-> If I have a body of text like this: "Foo bar foo"
-> And I say "find foo" - will 'find' locate both instances of 'foo?'

Hi, Terry,

The Python code is this:

    m = regexp.search(page)
    local_dict['__match__'] = m.group()

'search' stops at the first match, so all you'll get is the first match.


More information about the twill mailing list