php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #17504 Returning all email addresses found in a string with preg_match_all
Submitted: 2002-05-29 05:49 UTC Modified: 2002-06-28 03:19 UTC
From: toby dot beresford at ship-uk dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.2.1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: toby dot beresford at ship-uk dot com
New email:
PHP Version: OS:

 

 [2002-05-29 05:49 UTC] toby dot beresford at ship-uk dot com
This code searches a string and returns all the email addresses in it.

preg_match_all("(([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4})",$StringToSearch,$matches);

for ($b=0; $b<sizeof($matches[0]); $b++) {
	echo $matches[0][$b]."<br>";
}

-toby

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-29 06:15 UTC] cynic@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.

 [2002-05-29 06:21 UTC] sander@php.net
What do you want us to do with this?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 01:01:35 2025 UTC