Create regular expressions with natural, human language. Cheat Sheet: Full documentation available here. Match 'hello world' matches 'hello world' exactly match 'hello' then optionally ' world' matches 'hello' or 'hello world' match 'hello' or 'world' matches 'hello' or 'world' match a word matches any word. Regular Expression Tester with highlighting for Javascript and PCRE. Quickly test and debug your regex. Toggle navigation. RegEx Testing From Dan's Tools. HTML/JS/CSS Playground. Top Regular Expressions. Match string not containing string. Character classes. Any character except newline w d s: word, digit, whitespace. Regular Expression Flags; i: Ignore case: m ^ and $ match start and end of line: s. Matches newline as well: x: Allow spaces and comments: J: Duplicate group names allowed: U: Ungreedy quantifiers (?iLmsux) Set flags within regex. No Comments on Regex: Pattern Modifiers Cheat Sheet; g: Global match: i. Case-insensitive: m. Multiple lines: s. Treat string as single line: x. Allow comments and whitespace in pattern: e. Evaluate replacement: U. Ungreedy pattern. PCRE modifier. Tags Regex Cheat Sheet. Regular Expressions Cheat Sheet by Dave Child (DaveChild) via cheatography.com/1/cs/5/ Anchors ^ Start of string, or start of line in multi-line pattern.
AnchorsStart of string, or start of line in multi-line pattern | Start of string | End of string, or end of line in multi-line pattern | End of string | Word boundary | Not word boundary | Start of word | End of word |
Character ClassesControl character | White space | Not white space | Digit | Not digit | Word | Not word | Hexadecimal digit | Octal digit |
POSIXUpper case letters | Lower case letters | All letters | Digits and letters | Digits | Hexadecimal digits | Punctuation | Space and tab | Blank characters | Control characters | Printed characters | Printed characters and spaces | Digits, letters and underscore |
AssertionsLookahead assertion | Negative lookahead | Lookbehind assertion | Negative lookbehind | Once-only Subexpression | Condition [if then] | Condition [if then else] | Comment |
| Quantifiers0 or more | Exactly 3 | 1 or more | 3 or more | 0 or 1 | 3, 4 or 5 |
Escape SequencesEscape following character | Begin literal sequence | End literal sequence |
“Escaping” is a way of treating characters which have a special meaning in regular expressions literally, rather than as special characters. Special CharactersNew line | Carriage return | Tab | Vertical tab | Form feed | Octal character xxx | Hex character hh |
| Groups and RangesAny character except new line (n) | a or b | Group | Passive (non-capturing) group | Range (a or b or c) | Not (a or b or c) | Lower case letter from a to q | Upper case letter from A to Q | Digit from 0 to 7 | Group/subpattern number “x” |
Pattern ModifiersGlobal match | Case-insensitive | Multiple lines | Treat string as single line | Allow comments and whitespace in pattern | Evaluate replacement | Ungreedy pattern |
String Replacementnth non-passive group | “xyz” in /^(abc(xyz))$/ | “xyz” in /^(?:abc)(xyz)$/ | Before matched string | After matched string | Last matched string | Entire matched string |
|
Pcre Regex Cheat Sheet Download
Pcre Cheat Sheet
Made by Dave Child