How to extract numeric ID from URL using Airtable Regex

Hey everyone! I’m trying to figure out how to get just the numeric ID from a URL in Airtable using Regex. Here’s what I’m working with:

Target Audience field: https://example-store.com/segment?id=9876543210

I want to extract only the 9876543210 part. I’ve tried this formula:

IF(
REGEX_MATCH({Audience URL}, "=\d+"),
SUBSTITUTE(
REGEX_EXTRACT({Audience URL}, "=\d+"),
"=",
""
)
)

But it’s not quite right. Some URLs have extra stuff after the ID, like &tag=orders&onsite=1234. How can I make sure I only get the ID number? Any help would be awesome!

hey neo_movies, i think i can help. try this formula:

IF(
REGEX_MATCH({Audience URL}, “id=\d+”),
REGEX_EXTRACT({Audience URL}, “id=(\d+)”)
)

this should grab just the ID number, even if theres extra stuff after it. lemme know if it works!

I’ve dealt with similar URL parsing issues in Airtable before, and I think I can offer a solution that might work for you. Try this formula:

IF(
REGEX_MATCH({Audience URL}, “id=(\d+)”),
REGEX_EXTRACT({Audience URL}, “id=(\d+)”)
)

This should extract just the numeric ID after ‘id=’ in your URL, even if there are additional parameters afterward. The key is using parentheses to create a capture group for just the digits.

I’ve found this approach to be pretty robust, even with complex URLs. It’s saved me a lot of headaches when dealing with various API integrations that use different URL structures.

Let me know if you run into any issues with this formula. Sometimes URLs can be tricky, and you might need to tweak it depending on the exact format you’re dealing with.

I’ve worked with URL parsing in Airtable quite a bit, and I think I can offer a solution that should work for your case. Try this formula:

IF(
REGEX_MATCH({Audience URL}, “id=(\d+)”),
REGEX_EXTRACT({Audience URL}, “id=(\d+)”)
)

This formula will extract just the numeric ID after ‘id=’ in your URL, even if there are additional parameters afterward. The key is using parentheses to create a capture group for the digits.

I’ve found this approach to be reliable, even with complex URLs containing multiple parameters. It’s been a lifesaver when dealing with various API integrations that use different URL structures.

If you encounter any issues with this formula, let me know. URL formats can sometimes be tricky, and you might need to adjust it slightly depending on the exact structure you’re dealing with.