0
%\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b%

how do i make this understood for PHP

i want to find all email addresses in an html doc

1
  • unrelated to the question, but wanted to point out that email addresses can include apostrophes in the name (eg John.O'[email protected]). Commented Nov 8, 2010 at 19:58

2 Answers 2

1

PHP supports Perl regex through the preg_replace and preg_match functions. You don't need to change your regex at all.

Sign up to request clarification or add additional context in comments.

1 Comment

preg_match_all will generate a list of all matches. php.net/manual/en/function.preg-match-all.php
0

You may want to consider adjusting your regex to capture more address.

2 Comments

Warning: preg_match_all() [function.preg-match-all]: Delimiter must not be alphanumeric or backslash in parser.php on line 13 Warning: Invalid argument supplied for foreach() in parser.php on line 15 Warning: implode() [function.implode]: Invalid arguments passed in parser.php on line 18 \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b
@Dasa You have to put delimiters around it, like in Perl. preg_match('/your pattern/') See php.net/manual/en/regexp.reference.delimiters.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.