I’m trying to extract a numeric ID from a URL in Airtable. The URL is formatted like this:
https://example-site.com/segment?id=9876543210
I only require the number following ‘id=’ because some URLs have additional parameters appended to it. I attempted this formula:
IF(
REGEX_MATCH({URL Field}, "=\\d+"),
SUBSTITUTE(
REGEX_EXTRACT({URL Field}, "=\\d+"),
"=",
""
)
)
However, it’s not returning the desired result. Can someone help me adjust it so that only the ID number is extracted? Thanks!
I’ve dealt with similar URL parsing issues in Airtable before. Your approach is close, but you need to tweak the regex pattern slightly. Try this formula instead:
REGEX_EXTRACT({URL Field}, "id=(\d+)")
This pattern specifically looks for ‘id=’ followed by one or more digits, and captures just the numeric part. It should work even if there are additional parameters after the ID.
If you’re still having trouble, double-check that your URL field is consistently formatted. Sometimes inconsistencies in data can cause regex to fail unexpectedly. Let me know if this solves your problem!
hey, i’ve run into this before. try this:
REGEX_EXTRACT({URL Field}, ‘id=(\d+)’)
it grabs just the numbers after ‘id=’. works even with other stuff in the url.
let me know if it doesnt work for ya!
I’ve tackled this exact issue in my projects before. Your regex is close, but here’s a more robust solution that’s worked wonders for me:
REGEX_EXTRACT({URL Field}, ‘id=(\d+)’)
This pattern specifically targets the ‘id=’ parameter and captures only the numeric value after it. It’s been rock-solid in my experience, even with messy URLs that have additional parameters.
One pro tip: If you’re dealing with a large dataset, consider adding an error check:
IF(
REGEX_MATCH({URL Field}, ‘id=\d+’),
REGEX_EXTRACT({URL Field}, ‘id=(\d+)’),
‘No ID found’
)
This way, you’ll quickly spot any problematic URLs. Hope this helps streamline your workflow!