Possible Duplicate:
preg_replace how surround html attributes for a string with " in PHP
How to use preg_replace()
for change all word that is within <
>
and after =
for word with double quote surround
$var="<myfootball figure=thin new=aux(comment); > this=Association football < name=football >"
to
$var="<myfootball figure="thin" new="aux(comment);" >this=Association footballl< name="football" >"
What is the regular expresion for do this with preg_replace()
?
Replace
(?<==)(\b\w+\b)(?!")(?=[^<]*>)
with"$1"
EDIT (based on OP's comment and question update) >>
Replace
(?<==)(\b\S+?)(?=[\s>])(?!")(?=[^<]*>)
with"$1"
I think it is better to put this in 2 regular expressions. The first expressions matches everything between
<
and>
and the second expression quotes the text after=
.