Regex Task¶
Overview¶
The Regex Task uses regular expressions to extract, validate, replace, or match patterns in text. Use it for complex data extraction, input validation, text cleaning, or pattern-based transformations.
When to use this task:
- Extract specific patterns (emails, phones, URLs)
- Validate input formats
- Clean and normalize text
- Parse structured data from unstructured text
- Find and replace patterns
- Split text by complex patterns
- Extract multiple matches
- Data scraping and parsing
Key Features:
- Full regex pattern support
- Multiple extraction modes
- Capture groups
- Find and replace
- Match validation
- Global and case-insensitive matching
- Extract all matches
- Comprehensive output fields
Outputs¶
| Field | Type | Example | Notes |
|---|---|---|---|
response |
string | ORD-5560 |
The first match. Only the first — there are no group_1…group_9 fields. |
run |
boolean | true |
false when the pattern did not match. |
run_text |
string | Pattern matched. |
One match, not capture groups
The task returns the first match as a single string. To pull several values out of one piece of text, use one Regex task per value, or a Code task if you need capture groups.
Quick Start¶
Builder fields¶
The Field column is the label as it appears in the task builder; Key is the name the value is stored under and referenced by.
| Field | Key | Type | Default | Notes |
|---|---|---|---|---|
| Input | Input |
text | – | |
| Regex Pattern | Regex Pattern |
monospace | – |
- Add Regex task
- Select operation (Extract/Replace/Match)
- Input text to process
- Write regex pattern
- Test with sample data
- Save
Simple Example:
Operation: Extract
Input: {{task_49001_message}}
Pattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
Output: {{task_10001_response}} = the extracted email
Operations¶
Extract (Most Common)¶
Extract data matching pattern.
Configuration:
Output:
{{task_10001_response}}- the first match{{task_10001_run}}-truewhen the pattern matched
There is no all-matches, count or found field: the task returns the first match only.
Replace¶
Find pattern and replace with text.
Configuration:
Operation: Replace
Input: {{task_49001_text}}
Pattern: \d{3}-\d{3}-\d{4}
Replace With: [PHONE REDACTED]
Output:
{{task_10001_response}}- the resulting text
Match/Validate¶
Check if text matches pattern.
Configuration:
Operation: Match
Input: {{task_49001_email}}
Pattern: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Output:
{{task_10001_run}}-truewhen the input matched the pattern
Common Patterns¶
Email Addresses¶
Pattern:
Example:
Input: "Contact us at support@example.com or sales@company.org"
Output: {{task_10001_response}} → "support@example.com"
Output: {{task_10001_response}} → "support@example.com, sales@company.org"
Phone Numbers¶
US Format (123-456-7890):
International (+1-123-456-7890):
Example:
Input: "Call me at 555-123-4567 or +1-555-987-6543"
Output: {{task_10001_response}} → "555-123-4567, +1-555-987-6543"
URLs¶
Pattern:
Example:
Input: "Visit https://example.com or http://test.org/page"
Output: {{task_10001_response}} → "https://example.com, http://test.org/page"
Numbers¶
Integers:
Decimals:
Currency:
Example:
Input: "Total: $1,234.56 and shipping: $45.00"
Pattern: \$\d+(?:,\d{3})*(?:\.\d{2})?
Output: {{task_10001_response}} → "$1,234.56, $45.00"
Dates¶
MM/DD/YYYY:
YYYY-MM-DD:
Example:
Input: "Event on 02/08/2026 or 2026-02-08"
Pattern: \d{4}-\d{2}-\d{2}
Output: {{task_10001_response}} → "2026-02-08"
Usernames/IDs¶
Pattern:
Example:
Input: "Mentioned @john_doe and @jane_smith in the thread"
Output: {{task_10001_response}} → "@john_doe, @jane_smith"
Order/Invoice Numbers¶
Pattern:
Example:
Input: "Orders ORD-5560 and INV-12345 are ready"
Output: {{task_10001_response}} → "ORD-5560, INV-12345"
Capture Groups¶
Extract specific parts of matches.
Example - Extract Name and Email:
Pattern: ([A-Za-z\s]+)<([^>]+)>
Input: "John Doe <john@example.com>"
Outputs:
{{task_10001_response}} → "John Doe <john@example.com>" the first match, whole
Example - Extract Domain:
Pattern: @([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})
Input: "support@example.com"
Output:
{{task_10001_response}} → "example.com"
Example - Parse Order Details:
Pattern: Order\s+(\w+-\d+)\s+for\s+\$(\d+\.\d{2})
Input: "Order ORD-5560 for $129.99 shipped"
Outputs:
{{task_10001_response}} → "ORD-5560"
To also pull the amount, add a second Regex task with a pattern for the price.
Real-World Examples¶
Pull an order number out of an email¶
Email Trigger
└─ Regex pattern: (ORD|INV)-\d{4,}
└─ Edit Client record {{task_10001_response}} against the client
response holds the first match. If nothing matched, run is false.
Extract the sender's domain to tell business from personal¶
Form Submission
└─ Regex pattern: @([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})
└─ Key Match gmail.com → Personal, everything else → Business
Validate a reference before acting on it¶
Webhook In
└─ Regex pattern: ^[A-Z]{3}-\d{6}$
└─ If Statement run is true → continue, false → notify support
Used this way the task is a validator: run answers "does this look right?" and the workflow
branches on it.
Advanced Patterns¶
Lookahead and Lookbehind¶
Extract text between markers:
Extract price without currency symbol:
Non-Capturing Groups¶
Extract domain without protocol:
Pattern: https?://([a-z0-9.-]+)
Input: "https://example.com"
Output: {{task_10001_response}} → "example.com"
Alternation (OR)¶
Match multiple patterns:
Pattern: (Mr|Mrs|Ms|Dr)\.?\s+([A-Za-z]+)
Input: "Dr. Smith and Ms. Jones"
Outputs multiple matches with titles and names
Greedy vs Non-Greedy¶
Greedy (default):
Non-Greedy:
Flags and Options¶
Case Insensitive¶
Match regardless of case:
Global¶
Find all matches (not just first):
Multiline¶
^ and $ match line starts/ends:
Best Practices¶
Pattern Design¶
- Be specific - Narrow patterns reduce false matches
- Test thoroughly - Use regex testers (regex101.com)
- Escape special characters -
.,*,+,?,[,],(,),{,},^,$,|,\ - Use character classes -
\dfor digits,\wfor word chars - Anchor when validating - Use
^and$for full string match
Performance¶
- Avoid catastrophic backtracking - Be careful with nested quantifiers
- Use specific patterns -
\d{3}better than.+for 3 digits - Limit scope - Extract small text sections first
- Cache patterns - Reuse same regex in Variable task
- Don't overuse - Simple string operations might be faster
Maintainability¶
- Comment complex patterns - Document what pattern does
- Break into steps - Multiple simple regex > one complex
- Test edge cases - Empty strings, special characters
- Provide examples - Document expected inputs/outputs
- Version patterns - Track changes to regex patterns
Data Quality¶
- Validate before extract - Check if text exists
- Handle no matches - Provide defaults
- Trim whitespace - Clean extracted data
- Validate extractions - Verify format of extracted data
- Log failures - Track when patterns don't match
Troubleshooting¶
Pattern Not Matching¶
Check:
- Escape special characters (
\. \$ \*etc.) - Case sensitivity needed?
- Anchors correct (^ and $)?
- Pattern tested on actual data?
Debug: Test pattern at regex101.com with sample input
Too Many/Wrong Matches¶
Issue: Extracting unwanted text
Solutions:
- Make pattern more specific
- Use anchors (^ $)
- Use non-greedy quantifiers (? after + or *)
- Add negative lookaheads
Capture Groups Not Working¶
Issue: {{task_10001_response}} is empty
Check:
- Using parentheses
()for groups? - Pattern actually matching?
- Accessing correct group number?
Example:
Performance Issues¶
Issue: Regex takes too long
Causes:
- Catastrophic backtracking
- Very long input text
- Overly complex pattern
Solutions:
- Simplify pattern
- Use more specific character classes
- Process smaller chunks
- Use Code task for complex parsing
Special Characters Breaking Pattern¶
Issue: Pattern fails with special input
Solution: Escape special regex characters:
Frequently Asked Questions¶
What regex flavor does BaseCloud use?¶
JavaScript regex (ECMAScript). Most common patterns supported.
Can I test patterns before deploying?¶
Yes, use regex101.com with JavaScript flavor selected.
Can I use capture groups?¶
Not as separate outputs. The task returns the first match in response, and there are no
group_N fields. For several values from one string, use one Regex task per value, or a
Code task, which gives you the full match array.
Can regex replace variables?¶
No, replacement is static text. Use Code task for dynamic replacements.
What if no match found?¶
No match: {{task_10001_run}} is false and response is empty.
Can I extract all matches separately?¶
Yes, use Global flag. Access via {{task_10001_response}} (comma-separated).
How to match across multiple lines?¶
Use Multiline flag (m) and DOTALL flag (s) if available.
Can regex parse HTML/XML?¶
Not recommended. Use dedicated parser or Code task with DOM methods.
How to make pattern optional?¶
Use ? quantifier: https? matches "http" or "https"
Related Tasks¶
- Code Task - Complex text processing
- Formatter Task - Simple text transformations
- If Task - Conditional logic based on regex results
- Variable Task - Store regex results
- Phone Formatter - Phone-specific patterns