Available on plans:
Free
Pro
Team
Enterprise
Formatter's Extract Pattern transform allows you to find and use text that's part of a field by using a pattern (a Python regex) to search for it. This can be useful, for example, if you need data such as a name, but it's within a field that also contains the person's phone number and you need it separately.
Regex is an advanced feature, and Zapier Support cannot offer help with it. If you encounter a problem, reach out to the Zapier Community or StackOverflow. You can also try one of the ready-made extract transforms for phone number, URL, number, and email address.
1. Add a Formatter step to your Zap
- In the Zap editor, click the Action step. A dialog box will open.
- In the search box, search for and select Formatter. The right sidebar will open to the Setup tab.
- Click the Action event dropdown menu and select Text.
- Click Continue.
2. Set up your transform
- Click the Transform dropdown menu and select Extract pattern.
- In the Input field, select a field from a previous step you want to extract content from.
- In the Pattern field, enter the Python regex you want to use.
- Click Continue.
The Input field also works with line items. It will look for the pattern in each item individually. However, if you select Yes in the Match All field, this Formatter step will not work with line items.
3. Optional: Set up regex options
You can use the following regex options to refine the search:
- Match All - Matches all occurrences of pattern within the field. Returns the results as line items. If this option is set to Yes, the Input field won't work with line items.
- MULTILINE - If your field contains multiple lines, this option allows ^ and $ to match the start and end of each line.
- DOTALL - Allow dot (.) to match a newline pattern. Normally, a dot (.) will match anything except for newlines.
- IGNORECASE - Ignore upper/lowercase differences when searching.
4. Optional: Create a group label (Match All only)
If you select Yes in the Match All option, you can create a label for the line item group, to help you identify them for use in your Zap later. You can do so with the following pattern:
(?P<label_name>your_pattern)
In this example, we want to create a group label called first_name, by using the pattern (?P<first_name>^\w+\s)
that will search for matches on the following content (as one field):
Jonny Mills - 45 Road Name
Marie Miller - 55 Road Name
The output then becomes the following (as separate fields):
- Jonny
- Marie
5. Test your step
- Click Test step. If anything is found, you'll see the results of the search.
If the regular expression finds a match, it will return it in the field Output. The content of this field can vary depending on the options you select. Each match will always return at least these fields:
0
- text of match_end
- last position of match in text_start
- first position of the match in the text_matched
- true or false based on the match
0
, the second match as 1
, and so on.
Once you've finished setting this step up, you can add another action to use the results of the Formatter step.