re.subn error - please help

Ajay abra9823 at mail.usyd.edu.au
Mon Jun 28 05:16:54 CEST 2004


hi!

i have a template file with the string
"<!-- *** INSERT CONTEXT DEF BOX *** -->"

in a main function i have
import cgi
import re
import utilities

# specify the filename of the template file
templateFile = "templates/template.html"
contextTemplateFile = "templates/contextTemplate.html"


templateHandle = open(templateFile, "r")  # open in read only mode
# read the entire file as a string
templateInput = templateHandle.read()
templateHandle.close()                    # close the file


templateHandle = open(contextTemplateFile, "r")  # open in read only mode
# read the entire file as a string
contextTemplateInput = templateHandle.read()
templateHandle.close()                    # close the file

subResult = re.subn("<!-- *** INSERT CONTEXT DEF BOX *** -->",
contextTemplateInput, templateInput)
if subResult[1] == 0:
    raise badTemplateException

however when i run this i get an error saying:
File "index.cgi", line 24, in ?
    subResult = re.subn("<!-- *** INSERT CONTEXT DEF BOX *** -->",
contextTempla
teInput, templateInput)
  File "/usr/local/lib/python2.3/sre.py", line 151, in subn
    return _compile(pattern, 0).subn(repl, string, count)
  File "/usr/local/lib/python2.3/sre.py", line 230, in _compile
    raise error, v # invalid expression
sre_constants.error: multiple repeat

please help

thanks


--
Ajay Brar,
CS Honours 2004
Smart Internet Technology Research Group





----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




More information about the Python-list mailing list