Regex Tester avatar

Regex Tester

Pricing

Pay per event

Go to Apify Store
Regex Tester

Regex Tester

This actor tests regular expression patterns against multiple test strings and returns all matches with positions and named groups. Useful for bulk regex testing, data extraction pattern validation, and text analysis.

Pricing

Pay per event

Rating

0.0

(0)

Developer

Stas Persiianenko

Stas Persiianenko

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

3 days ago

Last modified

Categories

Share

Test regex patterns against multiple strings.

What does Regex Tester do?

This actor tests regular expression patterns against multiple test strings and returns all matches with their positions and named capture groups. It supports all standard JavaScript regex flags and validates the pattern before execution. Useful for bulk regex testing, data extraction pattern validation, and automated text analysis workflows.

Use cases

  • Data engineer validating extraction patterns against sample data before deploying them in a production pipeline
  • Backend developer testing email, URL, or phone number regex patterns against a batch of real-world inputs
  • QA engineer verifying that input validation patterns correctly accept and reject test cases
  • Security analyst scanning log files or text dumps for patterns matching known threat indicators
  • Technical writer documenting regex patterns with concrete match examples for team reference

Why use Regex Tester?

  • Batch testing -- test one pattern against hundreds of strings in a single run instead of checking them manually
  • Full match details -- get match text, index position, and named capture groups for every match found
  • Pattern validation -- invalid regex patterns return a clear error message instead of crashing
  • All JavaScript flags -- supports g, i, m, s, and u flags for global, case-insensitive, multiline, dotAll, and Unicode matching
  • Structured JSON output -- results are clean JSON objects ready for downstream processing or integration
  • Pay-per-event pricing -- only $0.0005 per string tested, plus a one-time start fee

Input parameters

ParameterTypeRequiredDefaultDescription
patternstringYes--Regular expression pattern to test
flagsstringNogiRegex flags: g (global), i (case-insensitive), m (multiline), s (dotAll), u (Unicode)
testStringsstring[]Yes--List of strings to test the pattern against
{
"pattern": "\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b",
"flags": "gi",
"testStrings": ["Contact info@example.com", "No email here"]
}

Output example

Each test string produces a result object:

FieldTypeDescription
testStringstringThe original test string
patternstringThe regex pattern used
flagsstringThe regex flags applied
isMatchbooleanWhether the pattern matched
matchCountnumberNumber of matches found
matchesarrayArray of match objects with match, index, and groups
errorstringError message if the pattern is invalid
{
"testString": "Contact info@example.com or admin@test.org",
"pattern": "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}",
"flags": "gi",
"isMatch": true,
"matchCount": 2,
"matches": [
{ "match": "info@example.com", "index": 8, "groups": null },
{ "match": "admin@test.org", "index": 28, "groups": null }
],
"error": null
}

Output fields reference

FieldTypeDescription
testStringstringThe original test string
patternstringThe regex pattern that was tested
flagsstringThe regex flags that were applied
isMatchbooleanWhether the pattern produced at least one match
matchCountnumberTotal number of matches found in the string
matchesarrayArray of match objects, each with match (string), index (number), and groups (object or null)
errorstringError message if the pattern is invalid, otherwise null

How much does it cost?

EventPriceDescription
Start$0.035One-time per run
String tested$0.0005Per string tested

Example costs:

  • 10 test strings = $0.035 + (10 x $0.0005) = $0.04
  • 100 test strings = $0.035 + (100 x $0.0005) = $0.085
  • 1,000 test strings = $0.035 + (1,000 x $0.0005) = $0.535

Using the Apify API

You can start Regex Tester programmatically from your own applications using the Apify API. Below are examples in Node.js and Python.

Node.js

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_TOKEN' });
const run = await client.actor('automation-lab/regex-tester').call({
pattern: '\\d+',
testStrings: ['abc 123 def 456', 'no digits here'],
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);

Python

from apify_client import ApifyClient
client = ApifyClient('YOUR_TOKEN')
run = client.actor('automation-lab/regex-tester').call(run_input={
'pattern': r'\d+',
'testStrings': ['abc 123 def 456', 'no digits here'],
})
items = client.dataset(run['defaultDatasetId']).list_items().items
print(items)

Integrations

Regex Tester works with the full Apify integration ecosystem. Connect it to Make (formerly Integromat), Zapier, n8n, or Slack to test patterns as part of automated data validation workflows. Export results directly to Google Sheets, Amazon S3, or any webhook endpoint. You can also schedule recurring runs on the Apify platform to validate new data against your patterns on a timer.

Tips and best practices

  • Use raw strings in Python -- prefix your pattern with r (e.g., r'\d+') to avoid issues with backslash escaping in Python string literals.
  • Test with both matching and non-matching strings -- include strings you expect to fail so you can verify your pattern does not produce false positives.
  • Use named capture groups -- patterns like (?<email>[A-Za-z]+@[A-Za-z]+\.[a-z]+) return group names in the output, making results easier to process programmatically.
  • Start with the g flag -- the global flag ensures all matches in each string are found, not just the first one. This is the default behavior.
  • Validate before deploying -- use Regex Tester to verify extraction patterns before hard-coding them into scrapers or data pipelines.

FAQ

What regex engine does this actor use? The actor uses the JavaScript (V8) regular expression engine. Patterns should follow JavaScript regex syntax, which is compatible with most common regex features but does not support lookbehind assertions in all cases or some PCRE-specific features.

Can I test multiple patterns at once? Each run tests a single pattern against multiple strings. To test multiple patterns, run the actor once per pattern or use the Apify API to start multiple runs in parallel.

What happens if my regex pattern is invalid? The actor catches syntax errors in the pattern and returns them in the error field of each result object. The isMatch field will be false and matches will be empty.

Does this actor support lookahead and lookbehind? Yes. The actor runs on a modern V8 JavaScript engine that supports both lookahead ((?=...), (?!...)) and lookbehind ((?<=...), (?<!...)) assertions.