Re: [PHP] Trying to craft a regexp
From: Burhan Khalid (phplist_at_meidomus.com)
Date: 10/31/03
- Next message: Tom Rogers: "Re: [PHP] Oh, for a "sureset()" (orthogonal to isset())"
- Previous message: Luiz Gustavo Sarubi Macchi: "PHP and Interbase !"
- In reply to: Manuel VáZquez Acosta: "Trying to craft a regexp"
- Next in thread: Manuel VáZquez Acosta: "Re: [PHP] Trying to craft a regexp"
- Reply: Manuel VáZquez Acosta: "Re: [PHP] Trying to craft a regexp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 31 Oct 2003 14:51:23 +0300 To: Manuel Vázquez Acosta <manu@chasqui.cu>, php-general@lists.php.net
Manuel Vázquez Acosta wrote:
> Hi all:
>
> I'm trying to find every simple mail address in an HTML that is not inside
> an A tag.
>
> I have tried this regexp:
> (?<!maito\:)(\w+@\w+(?:\.\w+)+)(?![^<]*?</a>)
Try this (a little more comprehensive) :
preg_match_all("|<a(.*?)href=[\"'](.*?)[\"'](.*?)>(.*?)</a>|i",
$rawHTML, $arrayoflinks);
$links = array_unique($arrayoflinks[0]);
$href = array_unique($arrayoflinks[2]); //href=
$text = array_unique($arrayoflinks[4]); //link text
$text, $href, etc. are arrays. You can print_r() to find out what they
contain.
-- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com
- Next message: Tom Rogers: "Re: [PHP] Oh, for a "sureset()" (orthogonal to isset())"
- Previous message: Luiz Gustavo Sarubi Macchi: "PHP and Interbase !"
- In reply to: Manuel VáZquez Acosta: "Trying to craft a regexp"
- Next in thread: Manuel VáZquez Acosta: "Re: [PHP] Trying to craft a regexp"
- Reply: Manuel VáZquez Acosta: "Re: [PHP] Trying to craft a regexp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|