Skip to content
All tools

Regex Lab

Available

Build, test, debug and reuse regular expressions with live matches, unit tests, a curated library, compatibility analysis and safe local execution.

Runs locally. Your test data never leaves this browser.
//gm
JavaScript / ECMAScript·native browser execution
Highlighted match preview
INFO server ready
WARN retrying request
ERROR upstream timeout
DEBUG hidden diagnostics

Regex Library

Search curated recipes with descriptions, examples and ready-to-run tests, then load the complete recipe into your workspace.

Practical email address

validation · javascript

Matches a pragmatic email shape for UI validation without pretending to implement the full RFC grammar.

/^[^\s@]+@[^\s@]+\.[^\s@]+$/i
emailformsvalidation

UUID v4

validation · javascript

Matches canonical UUID version 4 strings with the correct version and variant nibble.

/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
uuididentifierapi

ISO date shape

dates · javascript

Matches YYYY-MM-DD text shape. Calendar validity such as leap years still belongs to date parsing.

/\b\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\b/g
dateisoyyyy-mm-dd

HEX color

validation · javascript

Matches three, four, six or eight digit CSS hexadecimal color values.

/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i
csscolorhexfrontend

Semantic version core

extraction · javascript

Extracts major, minor and patch numbers with optional prerelease and build metadata.

/\b(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<pre>[0-9A-Za-z.-]+))?(?:\+(?<build>[0-9A-Za-z.-]+))?\b/g
semverversionrelease

HTTP(S) URL

web · javascript

Finds HTTP and HTTPS URLs in prose. Use URL parsing for authoritative validation.

/https?:\/\/[^\s<>"]+/gi
urlhttphttpsweb

Key/value log fields

logs · javascript

Extracts simple key=value pairs and exposes key and value as named captures.

/(?<key>[A-Za-z_][\w.-]*)=(?<value>"[^"]*"|[^\s]+)/g
logskey-valueobservability

Log level

logs · javascript

Finds common application log levels as standalone words.

/\b(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\b/gi
logsleveldebugobservability

URL slug

validation · javascript

Matches lowercase URL slugs made of alphanumeric segments separated by single hyphens.

/^[a-z0-9]+(?:-[a-z0-9]+)*$/
slugurlrouting

IPv4 address

validation · javascript

Matches IPv4 octets from 0 to 255 without accepting over-range values.

/^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/
ipnetworkipv4

JWT compact shape

extraction · javascript

Finds strings shaped like a compact three-part JWT/JWS. It does not validate signatures or claims.

/\b[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\b/g
jwttokensecurity

Double quoted string

text · javascript

Extracts double-quoted strings while allowing escaped characters inside them.

/"(?:\\.|[^"\\])*"/g
stringquotesparser

Quick reference

Search common anchors, character classes, groups, lookarounds, quantifiers and operators.

All tokens

80 shown · 80 total tokens

\n

Newline character

Pattern
\r

Carriage return character

Pattern
\t

Tab character

Pattern
\0

Null character

Pattern
\f

Form feed character

Pattern
\v

Vertical tab character

Pattern
.

Any character except line terminators unless dotAll is enabled

Pattern
a|b

Alternation — match either expression

Pattern
\d

Any digit character

Pattern
\D

Any non-digit character

Pattern
\w

Any word character

Pattern
\W

Any non-word character

Pattern
\s

Any whitespace character

Pattern
\S

Any non-whitespace character

Pattern
[abc]

One character from the set

Pattern
[^abc]

One character not present in the set

Pattern
[a-z]

One character inside a range

Pattern
[a-zA-Z]

One character from multiple ranges

Pattern
[[:alnum:]]

POSIX letters and digits class

Patternpcre2
[[:alpha:]]

POSIX letters class

Patternpcre2
[[:digit:]]

POSIX decimal digits class

Patternpcre2
[[:space:]]

POSIX whitespace class

Patternpcre2
[[:word:]]

POSIX word-character class

Patternpcre2
^

Start of input, or start of line in multiline mode

Pattern
$

End of input, or end of line in multiline mode

Pattern
\A

Absolute start of string

Patternpcre2
\Z

End of string, or before its final line terminator

Patternpcre2
\z

Absolute end of string

Patternpcre2
\b

Word boundary

Pattern
\B

Non-word boundary

Pattern
\G

Start of the current match attempt

Patternpcre2
a?

Zero or one occurrence

Pattern
a*

Zero or more occurrences

Pattern
a+

One or more occurrences

Pattern
a{3}

Exactly three occurrences

Pattern
a{3,}

Three or more occurrences

Pattern
a{3,6}

Between three and six occurrences

Pattern
a*?

Lazy quantifier — consume as little as possible

Pattern
a*+

Possessive quantifier — do not backtrack

Patternpcre2
(...)

Capturing group

Pattern
(?:...)

Non-capturing group

Pattern
(?<name>...)

Named capturing group

Patternjavascript
(?P<name>...)

Python-style named capturing group

Patternpython
(?>...)

Atomic non-capturing group

Patternpcre2
(?#...)

Inline comment group

Patternpcre2
(?=...)

Positive lookahead assertion

Pattern
(?!...)

Negative lookahead assertion

Pattern
(?<=...)

Positive lookbehind assertion

Pattern
(?<!...)

Negative lookbehind assertion

Pattern
\1

Match text previously captured by group 1

Pattern
\k<name>

Match text captured by a named group

Patternjavascript
\k{name}

PCRE2 named backreference

Patternpcre2
\g{-1}

PCRE2 relative numeric backreference

Patternpcre2
g

Global matching

Flagjavascript
m

Multiline anchors

Flag
i

Case-insensitive matching

Flag
s

Dot matches line terminators

Flag
u

Unicode-aware matching

Flagjavascript
y

Sticky matching from the current lastIndex

Flagjavascript
x

Ignore pattern whitespace and allow comments

Flagpcre2
U

Invert default greediness

Flagpcre2
$&

Insert the complete match

Replacementjavascript
$1

Insert capture group 1

Replacement
$<name>

Insert a named capture group

Replacementjavascript
$$

Insert a literal dollar sign

Replacementjavascript
$`

Insert content before the match

Replacementjavascript
$'

Insert content after the match

Replacementjavascript
${1}

PCRE2 replacement capture group

Replacementpcre2
\p{Letter}

Match a Unicode property or script category

Pattern
\P{Letter}

Negated Unicode property or script category

Pattern
\X

Extended Unicode grapheme sequence

Patternpcre2
\R

Unicode newline sequence

Patternpcre2
\x20

Character by hexadecimal value

Pattern
\u{1F600}

Unicode code point escape

Patternjavascript
\Q...\E

Treat enclosed text as literals

Patternpcre2
\K

Reset the reported start of the current match

Patternpcre2
(*ACCEPT)

PCRE2 control verb — immediately accept the current match

Patternpcre2
(*FAIL)

PCRE2 control verb — force the current match path to fail

Patternpcre2
(*SKIP)

PCRE2 control verb — move the next match attempt forward

Patternpcre2
(*UTF)

Enable UTF mode in PCRE2

Patternpcre2

Isolated execution

JavaScript regular expressions run in a dedicated Web Worker with a hard timeout so a pathological pattern cannot freeze the Devary interface.

Portable by design

Choose a target regex flavor to inspect portability issues and generate code without pretending that one engine behaves like every runtime.

Private workspace

Patterns, samples, tests and imported tool handoffs remain in browser memory and are not sent to a Devary backend.

Practical guide

Test and debug regular expressions with real examples

Regex Lab executes JavaScript regular expressions against sample text in your browser. Learn how to inspect named captures, turn a pattern into repeatable tests, and check portability before using it in a project.

From pattern to verified behavior

  1. Choose the engine and mode

    Keep JavaScript / ECMAScript selected for actual matching. Choose Match to inspect occurrences; other target flavors provide compatibility analysis, not native execution.

  2. Supply a pattern and text

    Enter a pattern without slash delimiters, choose flags such as g for all occurrences and m for per-line anchors, then paste a representative sample. Inspect highlighted results and capture groups.

  3. Protect changes with tests

    Open Unit Tests to add positive and negative examples. After editing the pattern, rerun the cases to check whether the behavior still matches your expectations.

Reproducible examples

Extract levels and messages from application logs

In Match mode, paste the two log lines and use the pattern with gm. The named groups level and message capture each line separately; the expected values below are computed with Regex Lab's actual JavaScript matching engine.

Pattern

(?<level>INFO|WARN|ERROR)\s+(?<message>.+)

Flags

gm

Test text or cases

INFO server ready
ERROR upstream timeout

Expected outcome

INFO: server ready
ERROR: upstream timeout

Check hexadecimal color strings

In Unit Tests, add each line as a separate case. Expect the first input to match and the second not to match. The anchors reject a missing #, and flag i permits uppercase hexadecimal letters. ✓ means match and ✗ means no match.

Pattern

^#[0-9a-f]{6}$

Flags

i

Test text or cases

#0ea5e9
0ea5e9

Expected outcome

#0ea5e9 → ✓
0ea5e9 → ✗

Important limitations

JavaScript execution only

Live matches run with the browser's ECMAScript RegExp engine inside a worker with a time limit. A pattern that works here may behave differently in another language or library.

Compatibility is advisory

PCRE2, Python, Java, .NET, Go and Rust targets provide static checks and code snippets, not real execution in those runtimes. Always run tests in the intended environment.

Patterns may be expensive

An isolated worker protects this page from a long-running pattern, but does not prove that a regex is safe in your production service. Test long and adversarial inputs for backtracking.

Know where your samples go

The workspace processes patterns and sample strings locally; Devary does not upload them to its backend. Copying or exporting content and pasting it into another system is a separate action.

Frequently asked questions

Why does g change my match count?

Without g, JavaScript's matching operation normally returns only the first match. With g, Regex Lab collects repeated matches, including capture details, until the input is exhausted.

Does selecting Python run Python regex syntax?

No. Python is an analysis-only target here. Regex Lab highlights likely differences and generates snippets, but you must execute and verify the expression using Python's re module.

Can Regex Lab prove a pattern is secure?

No. Risk heuristics and a browser worker limit help during experimentation, but correctness, resource limits and input validation still need tests in your deployment runtime.