Saturday, 15 May 2010

preg replace - Regex pattern not working in a particular case -


I am trying to clean a CMS database: all content has inline style and I need to snatch them .

I have many nested tags, so I tags to & lt; H3 & gt; I'm trying to change with (I'm sure the headings are not nested) and then with the HTMLPurifier I'll clear the other tags.

I & lt; Span & gt; and <3> <3> / code>:

  $ string = preg_replace ('/ / span style = "line-height: 17pt; font- Family: Helphica; Color: RGB (85, 85, 85 \); font size: 13pt; font-weight: bold; "& gt; (. *?) & Lt; \ / span & gt; / ',' & Lt; h3 & gt; $ 1 & lt; / h3 & gt; ', $ string);   

It works in every situation for it:

  & lt; Font-family: helvetica; color: RGB (85, 85, 85); font-size: 13pt; font-weight: bold; "& gt;" Rhesio obsoosenza " -ra & lt; / Span & gt; Maybe there is a problem in the text.  

How can I fix it?

(. *?) / s>, '& lt; h3 & gt; $ 1 & lt; / h3 & gt;' $ String);

No comments:

Post a Comment