[SOLVED] Wits end with regex
Posted: Fri Feb 18, 2005 4:06 pm
Hi folks,
I'm trying to work with regular expressions, and it's taking me way longer than I think it should.
I'm working in a custom CMS where I need to pull out all email addresses. For this case, I don't need to worry about proper format (RFC-wise), I can safely assume all email addresses are going to be of the format: username@mydomain.ca.
The problem I'm having is my setup (it may not be my expression) only catches the first email address in the string, it doesn't match to the rest of them.
So far, my setup is basically:
[edit: the regex got screwed up when a forum plugin went haywire]
The result is:
Any idea why all the addresses aren't being caught?
I'm trying to work with regular expressions, and it's taking me way longer than I think it should.
I'm working in a custom CMS where I need to pull out all email addresses. For this case, I don't need to worry about proper format (RFC-wise), I can safely assume all email addresses are going to be of the format: username@mydomain.ca.
The problem I'm having is my setup (it may not be my expression) only catches the first email address in the string, it doesn't match to the rest of them.
So far, my setup is basically:
[edit: the regex got screwed up when a forum plugin went haywire]
Code: Select all
$pattern = "(ї^@]*@ї^\.]*\.ї\.a-z0-9]*ї\.a-z]{2,4})";
$page_contents = 'me@server.com, you@server.com';
eregi($pattern,$page_contents,$matches);
echo "<pre>";
print_r($matches);
echo "</pre>";Code: Select all
Array
(
[0] => me@server.com
[1] => me@server.com
)