Interpreter

How to extract a phone number from text with a regular expression

2026-05-27
Task

A phone number is embedded in free text, for example Phone: +1 (555) 123-4567 ext. 10. You need the main number in a separate field.

Short answer

Find the number with a preset or custom regex, keep the match, then normalize spaces, brackets and hyphens for the CRM format.

How to do it in Eofferix

  1. Open the settings of the field or column that should receive the phone number.
  2. Add a Regular expression rule; use the star button to choose a phone preset if needed.
  3. Select Keep only matching text to remove surrounding text.
  4. If the CRM accepts digits only, remove +, spaces, brackets and hyphens with the next rules.

A supplier can send a phone number as part of a longer value, for example Phone: +1 (415) 555-0198 ext. 24. In value settings, you can find the number with a regular expression, keep the matched fragment, and then normalize it.

The rule is available in value transformations for XML, JSON, and table sources. You can type the regular expression manually or choose a preset with the star button next to the pattern field.

Choose a regular expression from presets

For phone extraction, use the regular expression condition and the remove all except action. This action keeps the full matched fragment and removes the text around it.

  1. Open the value settings for the phone field.
  2. Add a rule and select the regular expression condition.
  3. Click the star button and choose a phone preset.
  4. Select remove all except as the action and save the rule.
Animation showing how to choose a phone regular expression from Eofferix presets
The preset inserts the pattern into the regular expression field; you can still edit it manually.

Option 1: keep the matched phone number

Use this when you need to remove text around the phone number but keep the number formatting from the source.

BeforeRuleAfter
Contact: +1 (415) 555-0198 ext. 24\+?\d[\d\s().-]{8,}\d + remove all except+1 (415) 555-0198
phone 1 212 555 0104\+?\d[\d\s().-]{8,}\d + remove all except1 212 555 0104

Option 2: normalize the number

If you need one leading plus sign, use a three-rule sequence: first keep the matched phone number, then remove every non-digit character with the regular expression \D+, and then add + at the beginning when the current value is not empty.

Sequential phone cleanup rules in Eofferix value settings
The second rule removes every non-digit character with a regular expression; the third rule adds a plus sign to a non-empty value.
BeforeSequenceAfter
Phone: +1 (415) 555-0198 ext. 24keep phone → remove \D+ → if the current value is not empty, add ++14155550198
1 212 555 0104keep phone → remove \D+ → if the current value is not empty, add ++12125550104

Process data faster with Eofferix

Create a free account to automate catalogs and price lists around your own rules.

Sign up