Leaderboard ad · 728×90
Regex Cheatsheet
Common regex syntax and examples. Copy patterns with one click and filter via search.
44 entries matched
Anchors4
^Start of string (start of each line with m flag)$End of string (end of each line with m flag)\bWord boundary\BNon-word boundaryCharacter classes10
\dA digit, same as [0-9]\DA non-digit\wA word character, same as [A-Za-z0-9_]\WA non-word character\sA whitespace character\SA non-whitespace character.Any character (except newline; includes it with s flag)[abc]Character set: matches a, b or c[^abc]Negated set: any character except a, b or c[a-z]Range: matches a to zQuantifiers9
*0 or more of the previous item (greedy)+1 or more of the previous item (greedy)?0 or 1 of the previous item (greedy){n}Exactly n times{n,}n or more times{n,m}Between n and m times*?0 or more (lazy, matches as few as possible)+?1 or more (lazy)??0 or 1 (lazy)Groups & references5
(abc)Capturing group, referenced later by \1(?:abc)Non-capturing group\1Backreference to capture group 1(?<year>\d{4})Named capture group\k<year>Named backreferenceLookaround4
(?=abc)Positive lookahead: followed by abc(?!abc)Negative lookahead: not followed by abc(?<=abc)Positive lookbehind: preceded by abc(?<!abc)Negative lookbehind: not preceded by abcFlags6
gGlobal: find all matchesiCase-insensitivemMultiline: ^ and $ match line boundariessDotall: . matches newlines toouUnicode modeySticky: match at lastIndex onlyCommon examples6
[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}Email addresshttps?:\/\/[^\s]+HTTP/HTTPS link^((25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(25[0-5]|2[0-4]\d|[01]?\d?\d)$IPv4 address^1[3-9]\d{9}$Mainland China mobile number^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$Date YYYY-MM-DD^#?([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$Hex color codeIn-content ad · responsive
Related Tools
My Browser Info
See your User-Agent, screen, CPU cores, timezone and other browser details.
World Clock
Live current time for major cities worldwide on one screen.
Time Zone Converter
Convert time between two cities for meetings across time zones.
Keyboard Keycode
Press any key to see its key name, code and keyCode for development.
Unicode Converter
Convert text to and from \u, U+ and HTML numeric Unicode formats.
Base Converter
Convert between binary, octal, decimal, hex and any base 2-36.