ToolHop.

ADVERT

๐Ÿงต Regex Cheatsheet

Anchors, character classes, quantifiers, flags, and real-world regex patterns you can paste into your next search.

Practical regex reference with search, one-click copy, and an inline tester.

Regex Tester

Validate patterns against sample text before deployment.

Compiled as /^\w+$/g

Matches: 0

Anchors and Boundaries

Control where matches begin and end.

PatternMeaningUsageCopy
^Start of string or lineAnchor both ends for strict validation.
$End of string or lineUseful for full-string matches.
\b / \BWord boundary / non-boundaryMatch standalone keywords.
\A / \ZAbsolute start / endSome engines support these outside JS.

Character Classes and Groups

Build expressive token classes.

PatternMeaningUsageCopy
.Any char except newlineUse dotall (s) to include newlines.
[abc]Character setUse ranges such as [a-zA-Z].
\d \w \sDigit, word char, whitespaceUppercase forms negate classes.
(?:...)Non-capturing groupGroups without backreferences.

Quantifiers

Define repetition counts.

PatternMeaningUsageCopy
*0 or moreUse *? for lazy matching.
+1 or moreRequired repeated token.
?0 or 1Optional token.
{min,max}Explicit boundsExample: {8,} for minimum length.

Lookarounds and References

Assert context without consuming characters.

PatternMeaningUsageCopy
(?=...)Positive lookaheadEnsure next pattern exists.
(?!...)Negative lookaheadEnsure next pattern does not exist.
(?<=...)Positive lookbehindMatch text preceded by pattern.
\1 \2BackreferencesReuse captured groups.

Copy-ready Patterns

Common starter expressions.

PatternMeaningUsageCopy
^[a-z0-9_-]{3,16}$Username (3-16 chars)Allows letters, digits, underscore, hyphen.
^\+?[0-9\s-]{7,}$Flexible phoneOptional plus, spaces, dashes.
^[\w.-]+@[\w.-]+\.[a-z]{2,}$Email-like stringLightweight client-side validation.
^https?:\/\/[\w.-]+HTTP/HTTPS URLFast scheme + domain check.

ADVERT

ADVERT