Eli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
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
Eli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
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
Yup.. that was a good point.. ;)
Take a look at this example:
?php
function tag_rep($tag)
{
return
reg_replace('/(?!\)(\S+)\s*=\s*(?![\'])([^\s\']+)(?![\'])/','\1=\2',$tag);
}
$html=p class=MsoNormal id=parfont size=3 face=\Comic Sans
MS\span lang=NL
Sorry for the spam.. here it is:
?php
function tag_rep($tag)
{
return
preg_replace('/(?!\)(\S+)\s*=\s*(?![\'])([^\s\']+)(?![\'])/','\1=\2',$tag);
}
$html=p class=MsoNormal id=parfont size=3 face=\Comic Sans
MS\span lang=NL style='font-size:12.0pt;font-family:\Comic Sans
MS\'a
Eli wrote:
BlackDex wrote:
Hello ppl,
I have a question about regex and html parsing.
I have the following code:
---
p class=MsoNormalfont size=3 face=Comic Sans MSspan lang=NL
style='font-size:12.0pt;font-family:Comic Sans
MS'nbsp;/span/font/p
you realise that that HTML ammounts the to the
Thx... it works almost :P
I Changed the code a bit so you can see the results quicker :).
It doesn't change every attribute/value. I think this has to do something
with the opening and closing of a tag .
My code:
---
?php
function tag_rep($tag)
{
return
Owkay.. i fixed it :).
Here is the final code.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Owkay i fixed it :D.
The regexp needed a /s (Pattern Modifier) also so that the .(DOT) also does
newlines :).
Now it is fixed...
Thank you very much Eli :)
/me is happy.
THE CODE:
---
?php
function tag_rep($tag)
{
return
BlackDex wrote:
Hello ppl,
I have a question about regex and html parsing.
I have the following code:
---
p class=MsoNormalfont size=3 face=Comic Sans MSspan 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
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
10 matches
Mail list logo