Forum Moderators: coopster

Message Too Old, No Replies

regular expressions

         

orion_rus

10:46 am on Nov 19, 2005 (gmt 0)

10+ Year Member



Hello world i need to analize multi link
if i analize such multilink
<a href='asdas'>hello</a>
<a href='asdas'>hello</a>
<a href='asdas'>hello</a>
<a href='asdas'>hello</a>
i use such expression with preg_match_all:
<a href=\'?"?([^"\' ]*)([^>]*)>([^<]*)<\/a>
but if link contains img like this:
<a href='asdas'><img src='asdsad' /></a>
<a href='asdas'><img src='asdsad' /></a>
<a href='asdas'><img src='asdsad' /></a>
<a href='asdas'><img src='asdsad' /></a>
i can't use ([^<]*) and if i make there (.*)
in this block would be
<img src='asdsad' /></a>
<a href='asdas'><img src='asdsad' /></a>
<a href='asdas'><img src='asdsad' /></a>
<a href='asdas'><img src='asdsad' />
but i need only <img src='asdsad' />
may be somebody can help me make unique string for both types of <a href>

Thanks in advance!

DeanC

9:31 pm on Nov 20, 2005 (gmt 0)

10+ Year Member



So you want to match all anchors that are not images?

Why not just loop through the returned array and strip any image tags from it :)?

coopster

2:24 am on Nov 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you just trying to trap everything in anchor tags?
$pattern = "/<a[^>]*>(.*)<\/a>/Uis";

orion_rus

4:45 pm on Nov 21, 2005 (gmt 0)

10+ Year Member



Thanks all for help! it works great!