How do you find a phone number or a username in the middle of a string? Sometimes you can use the Formatter Split text function, if the item will always be in the same place, but it’s not always that straight forward.
That’s where the Extract Pattern function for the Formatter app comes in. You can find the Extract Pattern transform under the ‘Text’ functions for the Formatter. What it allows you to do is to find and extract patterns in text.
The Extract Pattern function uses Regex to find the text that you need. Regex is short for ‘regular expression’ and it basically means that you’re giving a sample format for the step to find.
You can learn more about Regex, including seeing a few examples in our blog post: How to Extract Email Addresses, Phone Numbers, and Links From Text
Regular expression - Wikipedia
The post also has some useful resources, like the Regex wikipedia page, which explains the syntax (rules) of Regex.
Extract pattern is useful for pulling out user names, specific email or phone number types (eg emails from a specific domain).
Have you used Extract pattern before? Do you have an example that you can share with the community?
How about this: lets say you have a list of phone numbers:
0123-555-6789, 0123-555-4321, 0729-555-1234, 0123-555-891
And you want to extract any number that starts ’07’. The 07 number might appear anywhere in the list of numbers, so how would you get it?
How might you solve that using regex?
I'm no Regex expert but something like this should work for that sample phone numbers list. It doesn't validate the number of digits though :)
If anyone is looking for a regex playground, https://regex101.com/ is great for testing regex against a test string.
Here's a useful tool for anyone that likes to fiddle with Regex:
Haha looks like me and
@ikbelkirasan are both on it today 😅
Lol yeah we mentioned regex101 at the same time :D
It must be a useful tool then! Thanks for sharing 😀
Hi! Do any of you know whether the "positive lookbehind" feature is supported in the Extract Pattern function?