Regular expressions are extremely powerful – and complex. Fortunately, there are plenty of sources for good regular expressions that describe all kinds of patterns. This is how you turn a RegEx pattern into a regular expression engine:
$regex now is a highly specialized filter for extracting e-mail addresses from text. Use this to list all emails in $text: