Regex Tester - Test Regular Expressions Online
Test a regex against real text
Type a pattern between the slashes, set flags, and paste the text you want to search. Every match is highlighted in the text, and the list below shows each match with its index, length and capture groups. Results update as you type.
The tester uses your browser's JavaScript RegExp, so the results are what String.match,
matchAll and replace will see in your code. Up to 10,000 matches are listed.
Example
Pattern ^(\w+)=(.*)$ with flags gm, against:
HOST=localhost
PORT=5432
# comment
DEBUG=
gives three matches. PORT=5432 has $1 = PORT and $2 = 5432. DEBUG= matches
with an empty $2, and the comment line is skipped because # is not a word character. Remove the
m flag and nothing matches, because ^ and $ then refer to the whole string.
Gotchas that differ from other languages
-
.does not match a newline unless you add thesflag.[\s\S]is the old workaround. -
\dand\ware ASCII only, even withu. Use\p{L}with theuflag to match letters such as é or ß. -
In a JavaScript string literal you need to double every backslash: the pattern
\d+is writtennew RegExp("\\d+"). In this tester, type the pattern as you would between slashes. -
A regex with the
gflag keeps its position inlastIndex, so calling.test()twice on the same string can return true and then false.
Common patterns
- ISO date:
\d{4}-\d{2}-\d{2}(checks the shape, not that the date exists). - Loose email check:
^[^\s@]+@[^\s@]+\.[^\s@]+$. A full RFC 5322 regex is not worth it; send a confirmation email. - IPv4 address:
\b(?:\d{1,3}\.){3}\d{1,3}\b(also accepts 999.999.999.999). - Trailing whitespace:
[ \t]+$with themflag.
Related Tools
Epoch / Unix Timestamp Converter
Convert between Unix epoch timestamps and human-readable dates.
UUID Generator
Generate random v4 UUIDs for use in databases and APIs.
Colour Converter
Convert colours between HEX, RGB, and HSL formats.
Timezone Converter
Convert times between timezones with UTC offset display and common presets.