PublicSoftTools

Regex Tester Online Free

Test and debug regular expressions in real time — enter a pattern and test string to see matches highlighted instantly. Supports g, i, m, s flags and capture groups.

Regex Tester

//

How to Use the Regex Tester

  1. 1Enter your regular expression in the pattern field between the slashes. Toggle the g, i, m, and s flags as needed.
  2. 2Paste your test string into the text area below. Matches update live as you type.
  3. 3Each match shows the matched value, its character index, and any capture groups.
  4. 4If the pattern is invalid, the error message from the JavaScript engine is shown so you can pinpoint the syntax issue.

Common Regex Patterns Reference

The patterns below cover the most frequent use cases. Copy and paste them as a starting point, then adjust for your specific needs.

Useful Regex Patterns

Email Address

[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,} — matches most standard email addresses. Use with the i flag for case-insensitive matching.

URL

https?:\/\/[^\s/$.?#].[^\s]* — matches http and https URLs. Add the g flag to find all URLs in a block of text.

IP Address (IPv4)

\b(?:\d{1,3}\.){3}\d{1,3}\b — matches IPv4 addresses. Does not validate that each octet is 0–255; use additional logic for strict validation.

Date (YYYY-MM-DD)

\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) — matches ISO 8601 dates with basic month/day range checks.

Hex Colour

#(?:[0-9a-fA-F]{3}{1,2}) — matches 3-digit and 6-digit hex colour codes including the leading hash. Add the i flag for case-insensitive.

Digits Only

^\d+$ — validates that the entire string is digits only. Use with the m flag to apply per-line in multi-line input.

Frequently Asked Questions

What does each regex flag do?

g (global): find all matches instead of stopping at the first one. i (case insensitive): treat uppercase and lowercase as equal — /hello/i matches "Hello", "HELLO", and "hello". m (multiline): make ^ and $ match the start and end of each line rather than the entire string. s (dotAll): make the dot (.) match newline characters (\n, \r) in addition to all other characters — without this flag, . does not match newlines.

What is the difference between a match and a capture group?

A match is the entire substring that the regex matched. A capture group is a sub-portion of the match, created by wrapping part of the pattern in parentheses. For example, the pattern (\d+)-(\d+) applied to "2024-05" produces a full match of "2024-05", group 1 "2024", and group 2 "05". Named groups use the syntax (?<name>pattern) and can be referenced by name instead of index.

What does the "index" mean in the match results?

The index is the zero-based character position in the input string where the match begins. For example, if the input is "hello world" and the regex matches "world", the index is 6 (counting from 0: h=0, e=1, l=2, l=3, o=4, space=5, w=6). This is useful when you need to know where in the string a match occurred, not just what was matched.

Why does my regex work in my code but not here (or vice versa)?

This tester uses JavaScript's built-in RegExp engine. If your code uses a different language (Python, Java, Go, PHP), the regex syntax may differ. Common differences: Python uses (?P<name>) for named groups while JavaScript uses (?<name>); lookaheads and lookbehinds have different support levels; character class shortcuts like \w, \d may behave differently with Unicode; and some engines support possessive quantifiers or atomic groups that JavaScript does not.

How do I match a literal dot, bracket, or other special character?

In regex, these characters have special meaning: . * + ? ^ $ { } [ ] | ( ) \. To match them literally, escape them with a backslash. For example, to match a literal dot use \., to match a literal opening bracket use \[. The pattern 3\.14 matches the string "3.14" exactly (the unescaped 3.14 would also match "3x14").

What are greedy, lazy, and possessive quantifiers?

Greedy quantifiers (*, +, ?) match as much as possible. Lazy quantifiers (*?, +?, ??) match as little as possible. For example, <.+> applied to "<a><b>" with greedy matching returns the whole string "<a><b>"; with lazy matching (<.+?>) it returns "<a>" then "<b>". Possessive quantifiers (*+, ++) prevent backtracking entirely — JavaScript does not support possessive quantifiers, but they are available in Java and PCRE.

Is my test string or pattern sent to a server?

No. The regex engine used here is JavaScript's native RegExp, which runs entirely in your browser. Neither your pattern nor your test string is transmitted anywhere. You can safely test against sensitive log data, production strings, or proprietary content.