filter tag from contain text with regex

i try filter a text that contain html tags , i want filter <a> tags from inner text of <a> i try

string:

<li><a href='abc'>one</a></li><li><a href='cde'>two tag</a></li><a href='fgh'>tag three</a></li><a href='ijk'>four</a></li>

php :

preg_match_all("/\<a.*?href(?:\=|\s\=)(?:\\"|\')(.*?)(?:\\"|\').*?\>[^\/]*tag\<\/a\>/", $input_lines, $output_array);

result :

array(1
   0    =>  abc
)

correct answer is like below

array(1
   0    =>  cde,
   1   =>  fgh
)

what is wrong and how can get correct result

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s