๐ Regex Tester
/ /
0 matches found 0ms
๐ก Highlighted Matches
๐ฏ Capture Groups
๐ All Matches
๐ Regex Cheat Sheet โผ
Character Classes
. - Any character except newline\w - Word character [a-zA-Z0-9_]\W - Non-word character\d - Digit [0-9]\D - Non-digit\s - Whitespace\S - Non-whitespaceAnchors
^ - Start of string$ - End of string\b - Word boundary\B - Non-word boundaryQuantifiers
* - 0 or more+ - 1 or more? - 0 or 1{n} - Exactly n{n,} - n or more{n,m} - Between n and mGroups & Lookarounds
(abc) - Capture group(?:abc) - Non-capturing group(?=abc) - Positive lookahead(?!abc) - Negative lookahead(?<=abc) - Positive lookbehind(? - Negative lookbehind โ Frequently Asked Questions
What is a regular expression? +
A regular expression (regex) is a pattern used to match character combinations in strings. It's a powerful tool for searching, validating, and manipulating text. Regex patterns use special characters and syntax to define search criteria.
What do the flags mean? +
โข g (global): Find all matches, not just the first
โข m (multiline): ^ and $ match line breaks
โข i (case insensitive): Ignore case differences
โข s (dotAll): . matches newlines
โข u (unicode): Enable full Unicode support
How do capture groups work? +
Capture groups are parts of a regex pattern enclosed in parentheses (). They allow you to extract specific parts of a match. For example, in the pattern (\d{3})-(\d{4}), the first group captures the first 3 digits, and the second group captures the last 4 digits.
What are some common regex patterns? +
โข Email: \b\w+@\w+\.\w{2,}\b
โข Phone: \b\d{3}[-.]?\d{3}[-.]?\d{4}\b
โข URL: https?://[^\s]+
โข Date: \d{4}-\d{2}-\d{2}
โข IP Address: \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b How can I match special characters? +
To match special regex characters literally (like ., *, +, ?, etc.), you need to escape them with a backslash (\). For example, to match a literal period, use \. instead of just .