Programming interactive tool
Regular Expressions Interactive Demo
Test regex patterns, inspect capture groups, preview replacements, and learn common text-processing patterns in one browser-first teaching tool.
Local browser processingCapture groupsReplacement preview
Current run
Ready
0
Matches
gi
Flags
0
ms
The regex runs inside a browser worker and stops slow patterns to protect the page.
Try it yourself
Pattern, flags, and input text
Live results
Highlighted matches
Regular expressions are powerful tools for text processing.
CONTACT INFO:
- Emails: john.doe@example.com, support@company.co.uk, test_user-123@sub.domain.org
- Phone: (555) 123-4567, 555.123.4567, 5551234567, +1-555-123-4567
WEB AND TECH:
- URLs: https://www.example.com, http://subdomain.site.com/path?query=value
- IP addresses: 192.168.1.1, 10.0.0.255, 255.255.255.0
DATES AND CODE:
- Dates: 01/15/2023, 2023-05-18, 15-Jan-2023
function hello() { return "Hello, world!"; }
print(f"The answer is {42}")Capture groups
Match table
Matches and capture groups will appear here after the pattern matches the text.
Replace mode
Preview replacement
Replacement preview appears here.
How to teach it
Regex learning path
- 1. Start with literal text, then introduce character classes like
\dand\w. - 2. Add quantifiers such as
+,*, and{n,m}. - 3. Use capture groups to extract meaningful parts, such as date components or usernames.
- 4. Show flags one at a time so students see how matching behavior changes.
Reference
Common regex tokens
| Token | Meaning | Example |
|---|---|---|
| . | Any character except newline, unless DotAll is enabled. | a.c matches abc |
| ^ | Start of string, or start of line with multiline mode. | ^Error |
| $ | End of string, or end of line with multiline mode. | done$ |
| \d | Any digit from 0 to 9. | \d{4} |
| \w | Word character: letter, digit, or underscore. | \w+ |
| \s | Whitespace such as spaces, tabs, and line breaks. | \s+ |
| [abc] | One character from a set. | [aeiou] |
| [^abc] | One character not in a set. | [^0-9] |
| * | Zero or more repetitions. | go*gle |
| + | One or more repetitions. | \d+ |
| ? | Zero or one repetition, or lazy mode after another quantifier. | colou?r |
| {n,m} | Between n and m repetitions. | \d{2,4} |
| (...) | Capture a group for reuse or inspection. | (cat|dog) |
| (?<name>...) | Named capture group. | (?<year>\d{4}) |
| | | Either the left or right alternative. | jpg|png |