I have the following format for emails on a page <a href='mailto:xyz@xyz.com'>
that I am trying to match with a regex
I am currently using this:
$pattern = '#a[^>]+href="mailto:([^"]+)"[^>]*?>#is';
preg_match_all($pattern, $data, $matches);
foreach ($matches[1] as $key => $email) {
$emails[] = $email;
}
but it results in no match. $emails
is NULL
.
I am just learning regular expressions so please forgive the question! Can someone explain why it doesn't work and suggest a change? Thanks