Regex Match Problem

Robert Brewer fumanchu at amor.org
Wed Mar 10 17:24:33 CET 2004


bdwise wrote:
> something();something();
> document.thisForm.textBox1.focus();something();
> 
> And I want to find a part between the semicolons that ends in focus()
> and remove the entire value between the semicolons.
> 
> My Regular Expression looks like this but it is not matching, can
> anyone help?
> 
> ";([^.]*).focus()"

Not sure if this is the final result you wanted, but it should overcome
the major hurdles (like not escaping the parentheses ;)

>>> import re
>>> a =
"something();something();document.thisForm.textBox1.focus();something();
"
>>> re.search(r';([^;]*).focus\(\);', a).groups()
('document.thisForm.textBox1',)


Hope that helps.


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org




More information about the Python-list mailing list