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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -