Regular Expressions 101

Community Patterns

Strip Email ID from Name

10

Regular Expression
PCRE (PHP <7.3)

Description

Use this regex to select all characters up to the "<" bracket. Then, reverse the direction of the bracket to select the closing ">" bracket. It works across multiple lines. You can get an email list with only the IDs. This is the pattern it matches:

Alpha Person aperson@whatever.org

Step 1 (.) [$<$] gives you aperson@whatever.org> Step 2 [$.$] (.) gives you aperson@whatever.org

Submitted by Jonathan Davidar - 9 years ago