regex

Retrieve email using regex

ThisĀ horrendousĀ regular expression will parse a string and return a valid email address from it. $email = "<'Freddy'> fred@live.com"; preg_match('/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/', $email,…