Changing HTML file Question

Brett Irving balgorg at hotmail.com
Thu May 15 22:30:13 EDT 2003


"Fredrik Lundh" <fredrik at pythonware.com> wrote in message news:<mailman.1052905821.25207.python-list at python.org>...
> Brett Irving wrote:
> 
> > Ok I have been trying to use the re subn however it wont run and keeps
> > coming up with:
> >
> >  File "getinput.cgi", line 72, in ?
> >     DisplayForm()
> >  File "getinput.cgi", line 22, in DisplayForm
> >     Display(FormInput)
> >  File "getinput.cgi", line 48, in Display
> >     Content,TemplateInput)
> >  File "/usr/local/lib/python2.2/sre.py", line 151, in subn
> >     return _compile(pattern, 0).subn(repl, string, count)
> >  File "/usr/local/lib/python2.2/sre.py", line 229, in _compile
> >     raise error, v # invalid expression
> > sre_constants.error: multiple repeat
> >
> > I have a function Display(content) which takes in a form from a
> > function DisplayForm() as a string and which attempts to replace
> > everything that was in that form into a template.html file using:
> >
> > SubResult = re.subn("<!-- *** INSERT CONTENT HERE *** -->",
> >         Content,TemplateInput)
> >
> > ( I want to change the file where it says INSERT CONTENT HERE)
> >
> > Can anyone help.
> 
> "*" is the RE repeat code.
> 
> since you're replacing a constant string, I suggest using string.replace
> instead of a regular expression:
> 
>     marker = "<!-- *** INSERT CONTENT HERE *** -->")
>     page = template.replace(marker, content)
> 
> </F>

cool, thanks heaps




More information about the Python-list mailing list