Regex Tester -- Test Regular Expressions
Test and debug regular expressions with real-time match highlighting. Free online regex tester with flag toggles (g, i, m, s), match groups, and match count.
Regex Examples in Code
Regular expressions work similarly across languages. Here are common patterns:
JavaScript
// Test if a string matches
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
emailRegex.test('user@example.com'); // true
// Extract matches
const text = 'Call 555-1234 or 555-5678';
const phones = text.match(/\d{3}-\d{4}/g);
// ["555-1234", "555-5678"]
// Replace with regex
const cleaned = ' hello world '.replace(/\s+/g, ' ').trim();
// "hello world"
Python
import re
# Test if a string matches
if re.match(r'^[^\s@]+@[^\s@]+\.[^\s@]+$', 'user@example.com'):
print('Valid email')
# Find all matches
phones = re.findall(r'\d{3}-\d{4}', 'Call 555-1234 or 555-5678')
# ['555-1234', '555-5678']
# Named groups
m = re.search(r'(?P<year>\d{4})-(?P<month>\d{2})', '2026-04-10')
print(m.group('year')) # '2026'
print(m.group('month')) # '04'
Frequently Asked Questions
How do I test a regular expression?
Enter your regex pattern in the pattern field, type or paste your test string below, and matches are highlighted in real-time. Toggle flags (global, case-insensitive, multiline, dotAll) to modify matching behavior. Match count and group details are shown below.
What regex flags are supported?
This tool supports four flags: g (global - find all matches), i (case-insensitive), m (multiline - ^ and $ match line boundaries), and s (dotAll - dot matches newlines). Toggle each flag independently to see how it affects your matches.
Does this tool show capture groups?
Yes. When your regex contains capturing groups (parentheses), the tool displays each group's matched content. Named groups and numbered groups are both shown, making it easy to debug complex patterns with multiple captures.
Is this regex tester JavaScript-compatible?
Yes. This tool uses JavaScript's native RegExp engine, so your patterns will work identically in any JavaScript environment (Node.js, browsers, Deno). The syntax and behavior match exactly what you would get in your code.
Is this tool free?
Yes. All KappaKit tools are free, run in your browser, and require no signup or account.