PHP regex - find and replace link -
i trying regex match , replace not able it.
example
<a href=one target=home>one</a> <a href=two>two</a> <a href=three target=head>three</a> <a href=four>four</a> <a href=five target=foot>five</a>
i want find each set of tags , replace this
find
<a href=one target=home>one</a>
change to
<a href='one'>one</a>
same way the rest of tags.
any appreciated!
use this:
preg_replace('/<a(.*)href=(")?([a-za-z]+)"? ?(.*)>(.*)<\/a>/', '<a href='$3'>$5</a>', '{{your data}}');
Comments
Post a Comment