Regex Help - Extract F&L Name, Email, Phone and text message

I've been able to modify older macros that @ccstone and @JMichaelTX provided me with.
I am able to get the First and Last Name and the email address extracted but cannot get the phone number or message extracted.
The text will always be formatted as the example
With the following:

Name
xxx
Email
xxx
Phone Number
xxx
Inquiry or Message
xxx

Any Help is appreciated.

Name
Troy LastName
Email
troytesting3@gmail.com
Phone Number
914 361-9012
Inquiry or Message
message as a test
to process

Assuming that your source text is always exactly the format that you posted, then this should work:
^Name\R(.+)\REmail\R(.+)\RPhone Number\R(.+)\RInquiry or Message\R(?s)(.+)

Note that this RegEx does NOT allow for any variation in your source text, like whitespace at the end of the field names. Of course, you can add that in.
The only cushion is that I use the RegEx metacharacter \R which will match any new line character.

For details, see:
https://regex101.com/r/ybVFLk/2/

If you have any questions, feel free to post, as always.

1 Like