Hey,
I am working on a html filter that doesn't allow <span> using strip_tags except for a <span> with the class header. So I thought I replace it with [nom1] and the </span> which ends it with [/nom1]. After that I can strip the <span> tag en replace [nom1] back to what It was. Problem is that I can't find a way to get this replace working correct.
For Example, this replace works as long as there is only 1 <SPAN class="header"> in the content. The problem is that it doesn't stop when encountering the first </SPAN> but continous till the last </SPAN> in the content.
insertText = eregi_replace('<SPAN class=["]header["]>(.*)</SPAN>','[nom1]\1[/nom1]',$insertText);
So when insertText = "<SPAN class=header>content bla something</SPAN> bla bla bla <SPAN class=header> bla again</SPAN> more";
It comes out as:
"[nom1]content bla something</SPAN> bla bla bla <SPAN class=header> bla again[/nom1] more";
So I think I need a replace which says find the span with the class="header" and then move on till It encounters </SPAN>. So:
insertText = eregi_replace('<SPAN class=["]header["]>([(</SPAN>)]+)</SPAN>','[nom1]\1[/nom1]',$insertText);
Where ([(</SPAN>)]+) is trying to be "is not </SPAN>". 🙁
Does anyone know how to do this correct?
Tomnie 😕