You are here: Re: PHP RegExp and HTML tags attributes values etc... « PHP « IT news, forums, messages
Re: PHP RegExp and HTML tags attributes values etc...

Posted by Eli on 10/04/35 11:10

BlackDex wrote:
> Hello ppl,
>
> I have a question about regex and html parsing.
>
> I have the following code:
> ---
> <p class=MsoNormal><font size=3 face="Comic Sans MS"><span lang=NL
> style='font-size:12.0pt;font-family:"Comic Sans MS"'>&nbsp;</span></font></p>
> ---
>
> It laks some quotemarks.
> I want to change it to:
> ---
> <p class="MsoNormal"><font size="3" face="Comic Sans MS"><span lang="NL"
> style='font-size:12.0pt;font-family:"Comic Sans MS"'>&nbsp;</span></font></p>
> ---
>
> So it will have " around the attribute values...
> But i can't figure out how to do that :(.
> Can anyone help me with this??
>
> Thx in advance.
> Kind Regards,
> BlackDex

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация