Replace and inserting strings within .txt files with the use of regex

Νίκος nikos.the.gr33k at gmail.com
Mon Aug 9 15:53:21 EDT 2010


On 9 Αύγ, 21:05, Thomas Jollans <tho... at jollybox.de> wrote:
> On Monday 09 August 2010, it occurred to Νίκος to exclaim:
>
>
>
>
>
> > On 9 Αύγ, 19:21, Peter Otten <__pete... at web.de> wrote:
> > > Νίκος wrote:
> > > > Please tell me that no matter what weird charhs has inside ic an still
> > > > open thosie fiels and make the neccessary replacements.
>
> > > Go back to 2.6 for the moment and defer learning about unicode until
> > > you're done with the conversion job.
>
> > You are correct again! 3.2 caused the problem, i switched to 2.7 and
> > now i donyt have that problem anymore. File is openign okey!
>
> > it ALMOST convert correctly!
>
> > # replace tags
> > print ( 'replacing php tags and contents within' )
> > src_data = re.sub( '<\?(.*?)\?>', '', src_data )
>
> > it only convert the first instance of php tages and not the rest?
> > But why?
>
> http://docs.python.org/library/re.html#re.S
>
> You probably need to pass the re.DOTALL flag.

 src_data = re.sub( '<\?(.*?)\?>', '', src_data, re.DOTALL )

like this?



More information about the Python-list mailing list