I want to get just ‘facebook’, ‘yelp’, or ‘google’ from these. I’m trying to use the Formatter tool in Zapier, but I’m lost with the Extract Pattern feature. I don’t know the right syntax for this.
Ideally, it would work for any URL. But if that’s too tricky, I could make a list of sites to look for.
Can anyone help me figure out the right RegEx pattern for this? I’m new to this and could really use some guidance. Thanks!
I’ve had to deal with this exact issue in one of my projects. Here’s what worked for me:
Use this regex pattern in Zapier’s Formatter tool: (?:a-z0-9?.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]
It’s a bit complex, but it handles a wide variety of URLs, including those with subdomains. Set the output format to {{1}} to get the full domain.
If you only want the main domain name without the TLD, you can use a second Formatter step with this pattern: ^(?:https?://)?(?:[^@\n]+@)?(?:www.)?([^:/\n?]+)
This two-step approach gives you more flexibility. You can adjust based on your specific needs.
Remember, regex can be tricky with edge cases, so test thoroughly with your actual data set.
I’ve tackled a similar challenge in Zapier before. The regex pattern you’re looking for is: (?:https?://)?(?:www.)?([^/]+)..+
This will extract the domain name without the TLD. In Zapier’s Formatter, use the ‘Extract Pattern’ action and input this regex. Set the ‘Output Format’ to {{1}} to get just the extracted domain.
For your specific examples, this would yield ‘facebook’, ‘yelp’, and ‘google’. It should work for most URLs, but be aware it might struggle with some complex subdomains or country-specific domains.
If you need more precision, you might want to consider using a dedicated URL parsing tool or creating a code step in Zapier for more advanced logic.
hey mate, i’ve used this regex before: (?<=://)(www.)?([^.]+)
it works pretty well for most urls. just pop it into zapier’s formatter with extract pattern. make sure to set output to {{2}} to grab just the domain name.
hope this helps ya out! lemme know if u need anything else