Extracting Numbers After Equals Signs in Airtable via Regex
In advanced workflow automation, you often encounter “dirty” strings where the data you actually need—like an Order ID, Customer Number, or Lead ID—is buried inside a URL or a concatenated string (e.g., status=active&user_id=99283&source=web).
While Airtable’s basic FIND and MID functions can handle simple parsing, they become brittle when string lengths vary. To build a resilient system, you must use Regular Expressions (Regex).
The “Aha!” Solution
Section titled “The “Aha!” Solution”Airtable’s REGEX_EXTRACT function returns the entire substring that matches a pattern. However, since Airtable does not support “Lookbehinds” (a regex feature that allows you to match a pattern only if preceded by another), simply searching for digits after an = sign often results in the = being included in your result.
The advanced workaround involves a two-step logic within a single formula:
- Extract the anchor (
=) and the following digits. - Substitute the anchor (
=) with an empty string to isolate the numerical value.
Alternatively, for more complex strings, using REGEX_REPLACE to strip away everything except the targeted capture group is the most robust method for automation.
Step-by-Step Implementation
Section titled “Step-by-Step Implementation”1. Prepare the Data Incoming via Webhook
Section titled “1. Prepare the Data Incoming via Webhook”If you are pushing data into Airtable via a webhook (e.g., from Make.com or Zapier), ensure your JSON payload delivers the string to a Single line text field.
Example Webhook JSON Payload:
{ "event_type": "order_completed", "metadata": "session_id=9928374&transaction_auth=88271", "airtable_record_id": "recQwerty123"}2. Create the Extraction Formula
Section titled “2. Create the Extraction Formula”Navigate to your table and create a new field. Set the field type to Formula.
To extract the number 9928374 from a field named {Metadata}, use the following formula:
| Goal | Formula |
|---|---|
| Simple Extraction | SUBSTITUTE(REGEX_EXTRACT({Metadata}, "=[0-9]+"), "=", "") |
| Robust Handling | IF({Metadata}, SUBSTITUTE(REGEX_EXTRACT({Metadata}, "=[0-9]+"), "=", ""), "") |
How it works:
REGEX_EXTRACT({Metadata}, "=[0-9]+"): Searches for the first instance of an equals sign followed by one or more digits. It returns=9928374.SUBSTITUTE(..., "=", ""): Takes that result and removes the=, leaving you with the pure numerical string.
3. Handling Specific Parameters in a Query String
Section titled “3. Handling Specific Parameters in a Query String”If your string has multiple equals signs (e.g., ?id=123&type=456) and you specifically need the value for type, the pattern must be more specific to avoid grabbing the first number found.
Formula for targeted extraction:
REGEX_REPLACE({Metadata}, ".*type=([0-9]+).*", "$1")
.*type=matches everything up to the word “type=”.([0-9]+)creates a capture group for the digits.$1tells Airtable to replace the entire string with only the contents of the first capture group.
Advanced Configuration: UI Path
Section titled “Advanced Configuration: UI Path”To implement this in your Airtable Base:
- Click the + icon to add a new field.
- Search for Formula.
- Paste the formula into the editor.
- Click Formatting and ensures “Permissions” are set to allow the data to be used in subsequent Automations.
- Go to Automations > Create Automation to trigger secondary actions (like a Slack notification) using this extracted ID.
Edge Cases & Limitations
Section titled “Edge Cases & Limitations”| Edge Case | Solution |
|---|---|
| Leading Zeros | The formula returns a string by default. If your IDs have leading zeros (e.g., 007), do not wrap the formula in VALUE(), as this will strip the zeros. |
| No Equals Sign | If the source field lacks an =, REGEX_EXTRACT will return an error. Use the IF() wrapper mentioned in Step 2 to keep the cell blank instead of showing #ERROR. |
| Multiple Numbers | If the string contains id=123 and ref=456, REGEX_EXTRACT only finds the first match. Use REGEX_REPLACE with a specific anchor word if you need the second or third value. |
| Non-Numerical IDs | If the ID contains letters (e.g., id=A123), change the regex pattern from [0-9]+ to [^&]+ (which matches every character until the next & or the end of the string). |
Note on Performance: Airtable formulas recalculate whenever the record is updated. For bases with over 50,000 records, complex Regex patterns can cause slight UI latency. Always anchor your Regex patterns (using ^ or $) where possible to improve calculation speed.