Regex Extraction in Email2LeadPro

Advanced Email Parsing Using $Rx and $Rx2 Markers

Email2LeadPro helps Salesforce administrators automatically extract structured information from incoming emails using regular expressions (RegEx).

This transforms unstructured email text into clean, consistent data for creating or updating Leads — saving hours of manual work.


Why Regular Expressions?

Most inquiry or contact emails follow a semi-structured format like:

Name: John Smith
Email: john.smith@acme.com
Phone: +1 408 555 1234
Message: Please call me regarding pricing.

Regular expressions allow Email2LeadPro to detect and extract such details even if spacing, punctuation, or capitalization vary slightly.


How It Works

Flow

Incoming Email Received → Email2LeadPro Parser Runs → Markers Evaluated (simple text markers or $Rx or $Rx2) → Enter regex in Starting Marker. Leave Ending Marker blank. → Regular Expression Applied → Matched Text Extracted → Mapped to Salesforce Lead Field → Lead Created or Updated

Step-by-step

  1. Incoming email arrives in the configured Email Service address.

  2. Parser runs and evaluates your Data Mappings in order.

  3. Marker check

    • Simple text markers are matched literally.

    • $Rx and $Rx2 markers trigger regex extraction.

  4. Admin input

    • Put your regular expression in Starting Marker.

    • Leave Ending Marker blank for regex-based extraction.

  5. Regex applied to the email body and capture groups are evaluated.

  6. Extraction

    • $Rx returns the selected capture group.

    • $Rx2 builds a formatted string from multiple groups.

  7. Mapping places the extracted value into the target Lead field.

  8. Lead is created or updated according to your app settings.

Quick syntax recap

  • $Rx:: or $Rx:n: followed by your pattern. Example:

    $Rx:1:(?i)Email:\s*([\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,})

  • $Rx2::<format>::<pattern> to combine groups. Example:

    $Rx2::$1 – $2::Name:\s*(.*?)\s*Phone:\s*([\+\d\-\s\(\)]+)

Admin tips

  • Use Validate in Configuration to test your extraction.

  • Prefer non-greedy quantifiers like .*? to avoid overmatching.

  • Keep one responsibility per mapping. Use separate mappings for unrelated fields.

  • If a simple text marker works, use it. Switch to $Rx for one value, $Rx2 for multi-value formatted output.


Full Feature Reference

$Rx – Simple Regular Expression Extraction

The $Rx marker is used when you need to extract a single value (such as an email address, phone number, or URL).

It’s lightweight, efficient, and ideal for most simple extraction cases.

Syntax

$Rx:n:<regex>

Where:

  • $Rx → identifies this as a regex extraction marker

  • n → capturing group number (0–7, default = 0)

  • <regex> → the regular expression pattern


Real-World Examples

Scenario / Purpose

Regex (Solution)

Test Link

Extract full URL appearing after marker *Listing:*

$Rx:1:(?s)(?:\*Listing:\*)\n(https:.*?)*?(\n)

Test Here

Extract clean phone number following the marker *Phone:*

$Rx:1:(?:\*Phone:\s?\*\s?)([\s+\d-()\w]*)\n

Test Here

Capture name after the second “Name:” in email text

$Rx:1:(?si)(?:Name:).*(?:Name:)([\s?\w+]*?\n)

Test Here

Capture phone after the second “Phone:” occurrence

$Rx:1:(?si)(?:Phone:).*(?:Phone:)([\s?+\d\w-()]*?\n)

Test Here

Extract a URL from a new line starting with “Listing:”

$Rx:1:(?si)(?:\n+\s*Listing:\s?)(\n*.*?\n)

Test Here

Capture an email address between the lines “Email” and “Phone”

$Rx:1:(?ims)^ *Email *$\s*([\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,})\s*^ *Phone *$

Test Here

Use Case: Ideal for extracting one field from a specific marker or pattern.

💡 Pro Tip: $Rx can be used in both Starting Marker and Override Value configurations.


$Rx2 – Advanced Multi-Field Extraction with Formatting

The $Rx2 marker provides enhanced control for extracting multiple pieces of information and formatting them into a single output.

Syntax

$Rx2::<format>::<pattern>

Where:

  • <format> defines how extracted groups will be combined (e.g., $1 – $2)

  • <pattern> is the regular expression that captures multiple fields


Practical Examples

Scenario / Purpose

Regex (Solution)

Output Example

Extract Name and Company and combine with a pipe

`$Rx2::$1

$2::Name:\s*(.?)\sCompany:\s*(.*)`

Extract Email and Phone from same block

$Rx2::$1 – $2::Email:\s*([\w\.\-]+@[a-zA-Z0-9\.\-]+)\s*Phone:\s*([\+\d\s\-\(\)]+)

john.smith@acme.com – +1 408 555 1234

Extract full Address (Street, City, State)

$Rx2::$1, $2, $3::Street:\s*(.*)\nCity:\s*(.*)\nState:\s*(.*)

500 Market Street, San Francisco, CA

Extract Product Inquiry Details

`$Rx2::Product: $1

Qty: $2

Use Case: Perfect for leads or inquiries containing multiple fields (Name, Company, Email, etc.)

💡 Pro Tip: $Rx2 supports multiple capture groups and full output formatting, so you can shape the final text exactly how you want it stored in Salesforce.


Testing and Validation

Before saving a regex expression in configuration:

  1. Open regex101.com.

  2. Paste a sample email body under Test String.

  3. Enter your pattern and verify the correct matches.

  4. Copy the final working pattern into your Email2LeadPro configuration.

  5. Use the Validate button to confirm the extraction result.


Quick Reference: Common RegEx Tokens

Token

Meaning

Example

.

Any single character

a.c matches abc

\d

Any digit

\d+ matches 123

\s

Whitespace (space, tab, newline)

\s* allows optional spaces

\w

Letters, digits, or underscores

\w+ matches User123

.*?

Non-greedy match (shortest possible)

Captures text until next marker

^ / $

Start / End of line

^Email matches “Email” at line start

( … )

Capturing group

(Name) captures “Name”

(?: … )

Non-capturing group

Groups logic without capturing

`

`

OR condition

(?i)

Case-insensitive mode

Matches Email or email


⚙️ Admin Tip

Start simple with $Rx for single-field extractions.

When you need to extract multiple related fields (like “Name, Email, and Phone”), switch to $Rx2 — it lets you format the result in one step before mapping it to Salesforce fields.