<?php $re = '/(?:(?:;|^)\h*(?<name>[^;<>]+)\h+<(?<email>[^<>\s@;]+@[^\s@<>;]+)>|(?<email>[^<>\s@;]+@[^\s@<>;]+))/J'; $str = 'jeff <jeff@store.com>; john <john@bbaft.com>; joe@company.com; jj@abc.info; jamie <jam@sub.abc.com>'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); foreach ($matches as $match) { echo sprintf("Name: %s\nEmail: %s\n\n", $match["name"], $match["email"]); }
You have javascript disabled. You will not be able to edit any code.