Python re - escape coincidental parentheses in regex pattern
I am having trouble with the regex in the following code: import mechanize import re br = mechanize.Browser() br.set_handle_robots(False) br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] response = br.open("http://www.gfsc.gg/The-Commission/Pages/Regulated-Entities.aspx?auto_click=1") html = response.read() br.select_form(nr=0) #print br.form br.set_all_readonly(False) next = re.search(r"""<a href="javascript:__doPostBack('(.*?)','(.*?)')">""",html) if next: print 'group(1):', next.group(1) print 'group(2)