Page 1 of 1

REGEX formula.

Posted: Tue May 26, 2009 12:58 am
by wren9
Hi i know this is very simple for REGEX old timer.

I have this link below,

Code: Select all

 
<a href="http://domain.org/tlg/1188777994.html">MANAGER NEEDED</a>
 
All i want is to get the text "MANAGER NEEDED" from that link.

I've been formulating for hours now and i'm completely lost i guess.

Anyone would to show the REGEX for this?

thanks in advance.

Re: REGEX formula.

Posted: Tue May 26, 2009 1:24 am
by wren9
Also how about i want to get the content of href which is "http://domain.org/tlg/1188777994.html" ?

Thanks again in advance.

Re: REGEX formula.

Posted: Tue May 26, 2009 3:22 am
by prometheuzz
Try something like this:

Code: Select all

preg_match(
  '#<a\s+href="([^"]+)"\s*>([^<]+)</a>#i', 
  '<a href="http://domain.org/tlg/1188777994.html">MANAGER NEEDED</a>', 
  $result
);
 
print_r($result);
/*
Array
(
    [0] => <a href="http://domain.org/tlg/1188777994.html">MANAGER NEEDED</a>
    [1] => http://domain.org/tlg/1188777994.html
    [2] => MANAGER NEEDED
)
*/