regular expression cheatsheet

Solutions on MaxInterview for regular expression cheatsheet by the best coders in the world

showing results for - "regular expression cheatsheet"
Isabelle
15 Sep 2016
1Regular Expression FUll Cheatsheet (For quick look) :)
2note: for downloading visit https://buggyprogrammer.com/regular-expression-cheatsheet/
3------x-------------------x----------------x------------x----------------x-------------
4
5# -------------- Anchors --------------
6^   →  Start of string, or start of line in multiline pattern
7\A  →  Start of string
8$   →  End of string, or end of line in multi-line pattern
9\Z  →  End of string
10\b  →  Word boundary
11\B  →  Not word boundary
12\<  →  Start of word
13\>  →  End of word
14
15
16# ---------- Character Classes --------
17\c  →  Control character
18\s  →  White space
19\S  →  Not white space
20\d  →  Digit
21\D  →  Not digit
22\w  →  Word
23\W  →  Not word
24\x  →  Hexadecimal digit
25\O  →  Octal digit
26
27
28# --------- Quantifiers -----------------
29*     →    0 or more 
30{3}   →    Exactly 3
31+     →    1 or more 
32{3,}  →    3 or more
33?     →    0 or 1 
34{3,5} →    3, 4 or 5
35Add a ? to a quantifier to make it ungreedy.
36
37
38# ------- Special Characters -------------
39\n   →  New line
40\r   →  Carriage return
41\t   →  Tab
42\v   →  Vertical tab
43\f   →  Form feed
44\xxx →  Octal character xxx
45\xhh →  Hex character hh
46
47
48# --------- Groups and Ranges -------------
49.       →  Any character except new line (\n)
50(a|b)   →  a or b
51(...)   →  Group
52(?:...) →  Passive (non-capturing) group
53[abc]   →  Range (a or b or c)
54[^abc]  →  Not (a or b or c)
55[a-q]   →  Lower case letter from a to q
56[A-Q]   →  Upper case letter from A to Q
57[0-7]   →  Digit from 0 to 7
58\x      →  Group/subpattern number "x"
59Ranges are inclusive.
60
61
62# ----------- Assertions ---------------
63?=         →  Lookahead assertion
64?!         →  Negative lookahead
65?<=        →  Lookbehind assertion
66?!= or ?<! →  Negative lookbehind
67?>         →  Once-only Subexpression
68?()        →  Condition [if then]
69?()|       →  Condition [if then else]
70?#         →  Comment
71
72
73# ------ Pattern Modifiers --------
74g   →  Global match
75i*  →  Case-insensitive
76m*  →  Multiple lines
77s*  →  Treat string as single line
78x*  →  Allow comments and whitespace in pattern
79e*  →  Evaluate replacement
80U*  →  Ungreedy pattern
81*   →  PCRE modifier
82
83
84# ------ String Replacement ------
85$n  →  nth non-passive group
86$2"xyz" in /^(abc(xyz))$/
87$1"xyz" in /^(?:abc)(xyz)$/
88$`  →  Before matched string
89$'  →  After matched string
90$+  →  Last matched string
91$&  →  Entire matched string
92Some regex implementations use \ instead of $
93
94
95# ---------- Escape Sequences ------------
96\ Escape following character
97\Q Begin literal sequence
98\E End literal sequence
99
100"Escaping" is a way of treating characters which have a special meaning in regular
101expressions literally, rather than as special characters.
102
103
104# --------- Common Metacharacters ---------
105^ 
106[
107.
108$
109{
110*
111(
112\
113+
114)
115|
116<
117>
118The escape character is usually \
119
120
121# ------------ POSIX ----------------
122[:upper:]  →  Upper case letters
123[:lower:]  →  Lower case letters
124[:alpha:]  →  All letters
125[:alnum:]  →  Digits and letters
126[:digit:]  →  Digits
127[:xdigit:] →  Hexadecimal digits
128[:punct:]  →  Punctuation
129[:blank:]  →  Space and tab
130[:space:]  →  Blank characters
131[:cntrl:]  →  Control characters
132[:graph:]  →  Printed characters
133[:print:]  →  Printed characters and spaces
134[:word:]   →  Digits, letters and underscore
Keith
02 Jan 2019
1/* shorthand character classes */
2regex = /d/; // matches any digit, short for [0-9]
3regex = /D/; // matches non-digits, short for [^0-9]
4regex = /S/; // matches non-white space character
5regex = /s/; // matches any white space character
6regex = /w/; // matches character, short for [a-zA-Z_0-9]
7regex = /W/; // matches non-word character [^w]
8regex = /b/; // Matches a word boundary where a word character is [a-zA-Z0-9_]
similar questions
python regex cheat sheet
queries leading to this page
regex 7b 7d 2a regular expressionregex with regular expression for 27 5ct regexuse regexregex 5ct 5e regexregex all characterscharacters in regex 5cd regex 25 in regexregex formatregular expression patternregular expression 3fregular expression and conditionregex guideregular expressionregex 2b 3fregex all regexp 28 2a 3f 29regex i charregex character 5cregex 24 characteregex 28 2a 3f 29regex 5c 24 2aregular expression listregex 5e 24regex char 40regex pcre cheat sheetcharacter regexreg expressionregex charachtersformatting regexregex cheat sheet 5c 25 regexregex characters are similarregex 5c 5c 7b 7d in regular expressionregex 21regexp char 40regex 28 22 2f 2a 2a 22 29regex caracter 7dregular matches expressionregex expressionsregex 5bregex 22 7c 22pattern regexregex character main idea of regex jean pagemaeaning of regexregex 2aregular expressionregular expression 3f 21regular expression 28 symbolregex 5dregex method cheat sheetregularexpression excharcters in regexregular expression 5c 2awhat is 2f in regexregex 22 5cd 22regular expression 2bregular expression letterregex for character 27 5c 27regex 3aregex coderegex lettersregular expression pattrenregex 28 3f 3aregex 23reg expr 7b 7dregular expression number of characters 3e 3e in regexregex for tableregular expression programming 2f regex characterall regex 5e regular expressionregular expression 5b 5dregex 22 7c 22 charregular expression cheatshettregular expression examples regular expression 40 in regexfind 3f 21 in regexregex symbol 28 29 in regex 24 in regexregualr expressionregex 22 3f 21 22regex contains all charactersregex to 2aregex charregex 5e 21 regexcheat sheet regexregex 7cregular expression symbol for 24regex charactrespattern regular expressionregular expression 2fsregular expression cheatsheetregular expression languageregex 7e characterregex e2 80 93 regular expressionregex 2cregex 5eregular expression in regexregex 5c 2f 5c 2f regex regex cheatsregex 28regular expressions regexregex meaningregex char 2fregex word 2a 7e regexregex 28 2a 29reg ex 25regex caracteresregex for 40 in regex regex 2b 23regex 28 3a 3fregex 5b 23 5dregular expression guideregular expressions syntaxregular expression 2b 24regular expression 29 in regexin regex 5c 3fregex 27regex charactersregular expressionregular expression for lettersregex meaningregular expression for 7cstring 7c 3e 3d 2what is a regular expression 5e regex meaning 3f 26 in regexregex 5b 5c 5dregular expressionregular expression 5b 3c 3e 2f 5dwhat does 28 29 mean in regexregex 27 2c 27 charregular expressionall characters regexregex 5e 5b 2f 5dregex expression 2awhat does 7d mean in regexregex specific characters onlyregular expressions special characters 24 in regular expression 2f in regexregex 5c 2bregex charsregex 3f 2areg exregex expressionlist of regexany word regexregular expression 7c 3a 5c 5c regex 3a in regexregex for regex string cheat sheetregular expression 5b 22 5d 5c regexregular expressionregex 7bregex 5cdregex search string cheat sheetwhat does 3f do in regexregex 3a 3fregex with charsregular expression cheat sheetregular expression for number of characters 5b 5d regexregular expressionregex 5c 27 in regexregex 3f 3a 28 3f 21regular expression defineregular expression letters 2fregexp syntaxregex 22 22regular expression 5c regular expressionregex letter site 3amedium com site 3atowardsdatascience comregular expressionregex fro 23use of 5e in regexregex 26regex patregular expression symbolsregular expressionregular expression 7b 7d 3f 3a 3a regexregex 27 27 27regular expression regular expression 5c 5cregex and on characterwhat does do in regexregular expression 2f 5cs 2a 28 3f 3a 3b 7c 24 29 5cs 2a 2fregex 2fregular expression 5eregex 3f 21 regular expressionregular expressionregex 28 3f 3c 21regex cheat 2a regex 2a 2a regex 5b 5e 5d in regex 21 in regex 2f 5e 5cd 2f regexregex for charactersd regex 2a 3f regexany regexregular expressionregular expressions lettersregex 2b 24regex symbols cheat sheetregex 2f 2fin regex expressionreguar expressionregular expressionregex 24 in regexwhat is 3d in regexregex 28 3f 21 29regex parameterswhats a regular expression 2f 2f 2a regex 2f 5e regexregex operators cheatsheet 5c 5c regexregex what isregex patternregular expression 2a 3f regexregular expression 40 symbolregex 2a 3fin regex 3fregex for 2b 2f 24 regexregular expression for symbolsregex printable characters 2b regular expressionregular expression language 2bregex 3fexpression regularlist of regular expressionsregex 28 3f regex 2f 22regular expression pattern table 3a in regexchar pattern regexregular expression for letterregex x caractereregular expression 2f characterregular expression letterswhat is regex expressionregex cheat shee 2a 2a 2f 2a regex meaningregular expressionregex 7eregex what is 3f 3aregex referenceregular expressionregex 5b 5e3 5dcheatsheet regex 2f regexregex syntaxreguler expressionregex symbolsregular expression 2f 2a in regular expression cheat sheetregular expression for 21 3f regex 22 2f 27regex rullesregex 2a regex 2c 2fregex 2f 5eregular show charactersregular expression definitionwhat is 5e in regexregex what are charactersreg exp syntaxregex referingregex 5c 3f 3a 5c 28 5c 3f 5c 21regex on of charactersregular expression 3f in regexcharacter in regular expressionregex 5c 24regex 2f 5e in regexregex 3d 2aregular expressionwhat is regular expression 2f 5cd 2f regexregex 5b 5e 5dwhat are regular expression regular expression syntaxregex 3a 3a 25 regular expression 3f 21 regex 22 2fi 22 regular expressionregex 5e meaningregexregex character listregex 3f character 28 in regexregex rulesregex commandsregex d 7b 7dregular expression 2aregex 28 3fregular expression sintaxregex 5e 2a regex 3f 3dregular expressionregex 5b 5dregular expression patternsregular expressionregular expression characterregex 5c 5c regex patternsregex match 24 characterregex 27 3a 27regex 5d 2a 29 2aregex carachterregex cheatsheet 2a regexregex 5b 5e 2f 5d 5c characters regex regex what is 3f regexbasic regular expressionsregex 3f 3a 5c 22 regexregex 5cregex sheet cheat 22 2a 3f 22 regexregular expressions symbolsregular expression for stringread regular expressionregular expression caractereregular expression explanation 2b in regexregex 2a characters 7c regex 28 29 meaning in regexregex 25 meaning 5e in regexwhat is 3f regular expression 5b 5cd 5d regexregex cheat sheetregex 5c 3a 24 meaning in regular expressionregex 2bdregex 22 27 22regex characterregular expression 3f 3dregular expressionregex expression cheat sheetregex 2f characterregex expression syntaxis 2b and 7c in regular expressionregex 2a characterstring regex cheat sheetregular expression 5b 5dregex 25 7b 7d regexregular expressionbest regex expressionregex 2fd regexregnex expressionlinux regex cheat sheet whitespaceregex characterregex text commandsregex commandall in regex 5b 5e 5cw 5cs 21 3f 24 3a 26 2c 5c 28 29 5d 2f regexregex pattern 2aregular exregex basics cheat sheetcharacters regexregex regular expression characterregex rules cheat sheetregex 2faregex 2b 2a 2fregex 21 24 23 25regex 3cregular expression cmndregular expression for name 7b 7d in regexregex cheat cheatregex 27 5c 27regex 2bregex all regex 5b 2f 5d 2a regexregex charatcersregular expression all charactersregular expression 3fregex with the character 22 22what is this regex expressionregular expression 28 29regex 22regular expression ireg expression lettersregex 2f 3eregular expression 28regex 40regex 3firegex 7c charregular expression 7b 7d 5b 5dregex for character 5bregex 2a and 2breference to every character regexregular expression php cheat sheetregular expression 2f 5b 5e 5c 5c 5c 2f 5d 2b 2fregular expression 2aregex for 28regex stringr cheat sheetregular expression explainedregular expression 5b 5dregex cheat sheetsregex pattern 2bregex 2f 2fregular expression 5cregex 2a 5c 5cregular expression characters 2f 2a regexwhat is the regular expression python regex tableregex symbol cheatsheetregex 40 characterwhat do the 5b 5d do in reg exwhat is in regexregex 3e 3cregular expression meaningregex listregex patterns cheat sheetregex 3dwhats this rex 2f 5ba za z 5d 2fregex 22 3f 22 5b 5c regexregex 2a 5c 2f regexiregex formatcheatsheet for regex 22 28 5b 7ca z 7ca z 7c 5d 2a 29 28 5c 5bd 5d 2a 29 22 regexhow to read regexlist regular expression cheat sheet regular expressionregex character 5b 3f regular expression characterregular expression match characters regexchar regex 5e 23 regexregex tableregex 28 characterregex basic syntaxregex 5c 3eregex 5b 2a 5d 5bregex cheat sheatregex dregex 3f 3d 7e regex regex cheat sheetregex simbolosregex caratregular expression excel cheat sheet 2a character regexregular expression special charactersregular expression for characters 3f 3a regexregexp charsregular expression fpr 3fregex regex 3f 3fregular expression 7eregular expression cheatsheet