PDA

View Full Version : Need help fine tuning preg_match_all


robbie
04-05-2001, 06:18 AM
Hi there,

I use:

$matches = preg_match_all(&quot;<a href="mailto:/(/([[a-z0-9_]|\\-|\\.)+@(([a-z0-9_">a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-">[a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}/">/([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}/</a>&quot;,$contents,$result);

to strip all e-mail addresses out of an html file.

It works fine, except for one thing. The output from such a query produces something like the following:

-----
email1@email.com
email2@email.com

h
s
h

co.

-----

Great that it gets the addresses... not so great that it matches those other characters. Anyone have any ideas on how to fix this?

Thanks
Rob

PaulKroll
04-05-2001, 11:13 AM
...why do you need to pull the e-mail addresses out of HTML pages...?

robbie
04-05-2001, 11:46 AM
Hmm... I just noticed now that my PHP statement did not display correctly:

I'll give it another try:


$matches = preg_match_all(&quot;<a href="mailto:/(/([[a-z0-9_]|\\-|\\.)+@(([a-z0-9_">a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-">[a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}/">/([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}/</a>&quot;,$contents,$result);