- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2023 09:17 PM - edited 01-25-2023 10:16 PM
You're welcome 🙂
Function match of a String means look for the patter in the string and return each find. The pattern, also called Regular Expression mean look for a sub-string that matches the rules:
- a line starting with text: From:
- followed by any number of white spaces: \s*
- followed by at least one of any kind of character: .+
- followed by any number of white spaces: \s*
- followed by a less-than character: <
- turn on capturing: (
- followed by at least one character that is neither less-than nor greater than: [^<>]+
- turn off capturing: )
- followed by a greater-than character: >
- followed by the end of a line
Capturing means that function match, in addition to returning the whole matched result, shall also return separately whatever fall between capturing delimiters. In our case the e-mail is captured.
To be honest, this could be simplified to:
/^From:.+<([^<>]+)>$/mi
Because we are no longer interested in anything (e.g. name) but the e-mail at the end.