Re: PHP RegExp and HTML tags attributes values etc...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Eli" <eli.hen@xxxxxxxxx> wrote in message news:20050310021553.57715.qmail@xxxxxxxxxxxxxxxx
> Eli wrote:
>>
>> Try:
>>
>> preg_replace('/(?<=\<)([^>]*)(\w+)=(?<!\'|\")([^>\s]+)(?=\s|\>)([^<]*)(?=\>)/U','\1\2="\3"\4',$html); Hmm.. that could be a 
>> start.. and don't ask me how it works... :P
>
> Well.. problem with that, is that if you got more than 1 un-escaped attribute in a tag, the regex will fix only the first 
> un-escaped attribute.
>
> for example, if $html is:
> <p class=MsoNormal id=par><font size=3 face="Comic Sans MS"><span lang=NL
> style='font-size:12.0pt;font-family:"Comic Sans MS"'>&nbsp;</span></font></p>
>
> In that case the id=par will remain as is...
> Does anyone knows how to improve it?

First of all thx :).

Just an idea... (Becouse im not that good at it).
Is it possible to create a while loop for the whole <....> part?
Simply sad...
while <.*?> do { parse the contents of that tag in someway and change it? }

Becouse i think it is imposible with RegEx alone to make it so that it can handle every attribute within a tag.

Ltrz BlackDex 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux