Need for parse strings which are appears in the following possible forms:
Some User Name
Some User Name <user.mail@address>
So username (multiple words) always exists but email is optional and contained in angle brackets.
I need to catch from those:
- Username, one string with multiple words separated by \s or \h
- Following next email address (if exists) without angle brackets. If no email address specified then resulting submask array should be empty (but always exists in result).
I tried some variations of
preg_match('/^(.*?)\s*(?:\<(.*)\>)?$/s', $in, $out)
but this not work.
Thanks anybody help me.