SlideShare a Scribd company logo
1 of 74
Download to read offline
Your Ultimate Cheatsheet
AIML Enthusiast
Om Pramod
By OM PRAMOD
1
The Python Regex Handbook: Your Ultimate Cheatsheet
Period (.)
By OM PRAMOD
2
The Python Regex Handbook: Your Ultimate Cheatsheet
* (Asterisk)
By OM PRAMOD
3
The Python Regex Handbook: Your Ultimate Cheatsheet
Caret (^)
By OM PRAMOD
4
The Python Regex Handbook: Your Ultimate Cheatsheet
$ (Dollar)
By OM PRAMOD
5
The Python Regex Handbook: Your Ultimate Cheatsheet
By OM PRAMOD
6
The Python Regex Handbook: Your Ultimate Cheatsheet
+ (Plus)
By OM PRAMOD
7
The Python Regex Handbook: Your Ultimate Cheatsheet
By OM PRAMOD
8
The Python Regex Handbook: Your Ultimate Cheatsheet
? (Question Mark)
By OM PRAMOD
9
The Python Regex Handbook: Your Ultimate Cheatsheet
| (Pipe)
By OM PRAMOD
10
The Python Regex Handbook: Your Ultimate Cheatsheet
() (Parentheses)
By OM PRAMOD
11
The Python Regex Handbook: Your Ultimate Cheatsheet
By OM PRAMOD
12
The Python Regex Handbook: Your Ultimate Cheatsheet
By OM PRAMOD
13
The Python Regex Handbook: Your Ultimate Cheatsheet
{} (Braces)
By OM PRAMOD
14
The Python Regex Handbook: Your Ultimate Cheatsheet
[] (Square Brackets)
By OM PRAMOD
15
The Python Regex Handbook: Your Ultimate Cheatsheet
By OM PRAMOD
16
The Python Regex Handbook: Your Ultimate Cheatsheet
 (Backslash)
w
By OM PRAMOD
17
The Python Regex Handbook: Your Ultimate Cheatsheet
W
By OM PRAMOD
18
The Python Regex Handbook: Your Ultimate Cheatsheet
s
By OM PRAMOD
19
The Python Regex Handbook: Your Ultimate Cheatsheet
S
By OM PRAMOD
20
The Python Regex Handbook: Your Ultimate Cheatsheet
d
By OM PRAMOD
21
The Python Regex Handbook: Your Ultimate Cheatsheet
By OM PRAMOD
22
The Python Regex Handbook: Your Ultimate Cheatsheet
D
By OM PRAMOD
23
The Python Regex Handbook: Your Ultimate Cheatsheet
b
By OM PRAMOD
24
The Python Regex Handbook: Your Ultimate Cheatsheet
By OM PRAMOD
25
The Python Regex Handbook: Your Ultimate Cheatsheet
B
By OM PRAMOD
26
The Python Regex Handbook: Your Ultimate Cheatsheet
A
By OM PRAMOD
27
The Python Regex Handbook: Your Ultimate Cheatsheet
Z
By OM PRAMOD
28
The Python Regex Handbook: Your Ultimate Cheatsheet
n
By OM PRAMOD
29
The Python Regex Handbook: Your Ultimate Cheatsheet
t
By OM PRAMOD
30
The Python Regex Handbook: Your Ultimate Cheatsheet
[a-z]
By OM PRAMOD
31
The Python Regex Handbook: Your Ultimate Cheatsheet
[A-Z]:
[arn]
By OM PRAMOD
32
The Python Regex Handbook: Your Ultimate Cheatsheet
[^arn]
[a-n]
By OM PRAMOD
33
The Python Regex Handbook: Your Ultimate Cheatsheet
[^a-n]
By OM PRAMOD
34
The Python Regex Handbook: Your Ultimate Cheatsheet
[^0-3]
[0123]
By OM PRAMOD
35
The Python Regex Handbook: Your Ultimate Cheatsheet
[0-9]
[0-5][0-9]
By OM PRAMOD
36
The Python Regex Handbook: Your Ultimate Cheatsheet
[a-zA-Z]
By OM PRAMOD
37
The Python Regex Handbook: Your Ultimate Cheatsheet
[a-zA-Z0-9]
{n}
By OM PRAMOD
38
The Python Regex Handbook: Your Ultimate Cheatsheet
{n,}
{,m}:
{n,m}
By OM PRAMOD
39
The Python Regex Handbook: Your Ultimate Cheatsheet
[]
Square
brackets
In regular expressions, square brackets ([]) are used to define a character set, which
is a set of characters you want to match. This can be useful when you want to match
any one character from a specific set of characters.
You can also use square brackets to match any character that is not in a specific set.
This is done by placing a caret (^) at the start of the character set
In addition to individual characters, you can also use a hyphen (-) inside square
brackets to specify a range of characters.
However, if you want to include a hyphen in your character set, you need to place it
at the start or end of the character set. This is because the hyphen is used to denote
a range in regular expressions. Placing it at the start or end ensures it is interpreted
as the literal character - and not as a range specifier.
By OM PRAMOD
40
The Python Regex Handbook: Your Ultimate Cheatsheet
In some cases, you might want to match the square brackets themselves as
characters. This can be done by escaping the square brackets with a backslash ().This
is because square brackets have a special meaning in regular expressions, denoting a
character set. By using a backslash, you’re indicating that you want to match the literal
character and not use its special meaning. For instance, For example, the regular
expression [ will match a single opening square bracket, and ] will match a single
closing square bracket.
. Period
In regular expressions, the dot (.) is a special character that matches any single
character except newline characters(This is an important aspect of regular
expressions to keep in mind when matching across multiple lines.). This means it can
represent any character from the alphabet, numbers, special characters, etc.
By OM PRAMOD
41
The Python Regex Handbook: Your Ultimate Cheatsheet
If you want to match a literal dot (.), you need to escape it using a backslash (). For
example, the regular expression . will match a single dot. This is because inside a
character class, the dot (.) loses its special meaning and matches a literal dot.
^ Caret
In regular expressions, the caret (^) is a special character that has different meanings
depending on its usage. Start of Line or String: When used at the start of a regular
expression, the caret (^) represents the start of a line or a string. For example, the
regular expression ^hello will match any string that starts with the word "hello".
Negation in Character Sets: When used inside square brackets ([]), the caret (^)
negates the set of characters. This means it will match any character that is not in the
set. For example, the regular expression [^abc] will match any character that is not 'a',
'b', or 'c'.
Literal Caret Character: If you want to match the actual caret (^) character, you need
to escape it using a backslash (). For example, the regular expression ^ will match a
single caret.
By OM PRAMOD
42
The Python Regex Handbook: Your Ultimate Cheatsheet
$ Dollar
In regular expressions, the dollar sign ($) is a special character that represents the end
of a line or a string.
* Star
In regular expressions, the asterisk (*) is a special character known as a quantifier that
specifies that the preceding character or group should be matched zero or more
times. This means it can match the preceding character or group any number of times,
including not at all.
If you want to match a literal asterisk (*), you need to escape it using a backslash ().
For example, the regular expression * will match a single asterisk. This is because
inside a character class, the asterisk (*) loses its special meaning and matches a literal
asterisk.
By OM PRAMOD
43
The Python Regex Handbook: Your Ultimate Cheatsheet
+ Plus
In regular expressions, the plus sign (+) is a special character known as a quantifier
that specifies that the preceding character or group should be matched one or more
times. This means it can match the preceding character or group at least once, but
possibly more.
If you want to match a literal plus sign (+), you need to escape it using a backslash ().
For example, the regular expression + will match a single plus sign. This is because
inside a character class, the plus sign (+) loses its special meaning and matches a literal
plus sign. This is an example of how escaping works in regular expressions. Escaping
is used to treat special characters as literal characters.
Inside a character class (denoted by square brackets []), the plus sign + loses its special
meaning and matches a literal plus sign. For example, the regular expression [+] will
match a single plus sign. This is because inside a character class, special characters
lose their special meaning and are treated as literal characters. This is another
important aspect of regular expressions to keep in mind.
By OM PRAMOD
44
The Python Regex Handbook: Your Ultimate Cheatsheet
?
Question
Mark
In regular expressions, the question mark (?) is a special character known as a
quantifier that specifies that the preceding character or group should be matched
zero or one times. This means it can match the preceding character or group either
once or not at all.
If you want to match a literal question mark (?), you need to escape it using a
backslash (). For example, the regular expression ? will match a single question
mark. This is because inside a character class, the question mark (?) loses its special
meaning and matches a literal question mark. Similarly, inside a character class
(denoted by square brackets []), most special characters lose their special meaning
and are treated as literal characters. So, [?] would also match a literal question mark
(?).
In addition to its role as a quantifier, the question mark (?) can also be used in certain
contexts to make a group optional or to apply modifiers to only part of the regular
expression. Optional Grouping: You can use the question mark to make an entire
By OM PRAMOD
45
The Python Regex Handbook: Your Ultimate Cheatsheet
group optional. This is done by surrounding the part of the pattern that should be
optional with parentheses (), and placing a question mark after the closing parenthesis
Modifiers: The question mark can also be used to apply modifiers to only part of the
regular expression. This is done by placing the modifier after a question mark inside
parentheses. In regular expressions, (?i) is a mode modifier that makes the rest of the
pattern case-insensitive. This means that the pattern will match regardless of whether
the characters are in uppercase or lowercase. For example, the pattern (?i) abc will
match abc, ABC, Abc, aBc, abC, ABc, aBC, and AbC. It’s a very useful feature when you
want to match a string regardless of its case. Please note that the ?i should be
enclosed in parentheses like this: (?i).
By OM PRAMOD
46
The Python Regex Handbook: Your Ultimate Cheatsheet
The (?=) syntax in regular expressions is known as a positive lookahead assertion. It is
used to assert that a certain pattern is ahead in the string, but it does not consume
any of the string. This means that the current position in the string remains the same
after the lookahead assertion. Lookahead assertions are particularly useful when you
want to match a pattern only if it's followed by another pattern, but you don't want
to include the second pattern in the match. For example, consider the regular
expression q(?=u)i. This expression will match a 'q' that is followed by a 'u', without
making the 'u' part of the match. The positive lookahead construct is a pair of
parentheses, with the opening parenthesis followed by a question mark and an equals
sign.
{} Braces
In regular expressions, curly braces ({}) are used as quantifiers to specify the exact
number of times a character or group should be matched. They are used in the format
{n}, where n is the exact number of times the preceding character or group should be
matched.
By OM PRAMOD
47
The Python Regex Handbook: Your Ultimate Cheatsheet
If you want to match a literal pair of curly braces ({}), you need to escape them using
a backslash (). For example, the regular expression {} will match a single pair of
curly braces. This is because inside a character class, the curly braces ({}) lose their
special meaning and match a literal pair of curly braces. Similarly, inside a character
class (denoted by square brackets []), most special characters lose their special
meaning and are treated as literal characters. So, [{}] would also match a literal pair
of curly braces ({}).
Curly braces can also be used in the format {n,} to match the preceding character or
group at least n times. For example, the regular expression a{2,} will match "aa",
"aaa", "aaaa", and so on.
the {,m} quantifier in regular expressions specifies that the preceding character or
group should be matched at most m times. Here m is a positive integer. If the
character or group appears more than m times, it will not be a match.
By OM PRAMOD
48
The Python Regex Handbook: Your Ultimate Cheatsheet
Similarly, curly braces can be used in the format {n,m} to match the preceding
character or group at least n times and at most m times. For example, the regular
expression a{2,3} will match "aa", "aaa"
|
Alternatio
n
In regular expressions, the pipe symbol (|) is used as an alternation operator, which
is similar to the logical OR operator. It allows you to match either the pattern before
the pipe or the pattern after the pipe.
() Group
In regular expressions, parentheses (()) are used for grouping and capturing.
Grouping: Parentheses are used to group parts of a regular expression together. This
allows you to apply a quantifier to the entire group or to restrict alternation to part of
the regular expression. Parentheses group parts of the pattern together. This allows
you to apply quantifiers to multiple characters instead of just one. For example, in the
pattern (abc)+, the + applies to the entire string abc, not just the character c.
By OM PRAMOD
49
The Python Regex Handbook: Your Ultimate Cheatsheet
Capturing: Besides grouping part of a regular expression together, parentheses also
create a numbered capturing group. It stores the part of the string matched by the
part of the regular expression inside the parentheses.
By OM PRAMOD
50
The Python Regex Handbook: Your Ultimate Cheatsheet
The (?i) keyword in regular expressions is used to perform case-insensitive matching.
When included in a regular expression, it makes the expression match the target string
regardless of the case of the characters. The (?i) keyword is particularly useful when
you're not sure of the exact casing of the string you're trying to match or when you
want to match multiple variations of a word or phrase. It allows you to write more
flexible and robust regular expressions that can handle different input formats. For
example, the regular expression /python/ would only match strings that contain the
word "python" in lowercase. However, if you add (?i) to the beginning of the
expression, like /(?i)python/, it will match strings that contain "python" in any
combination of uppercase and lowercase letters, such as "Python", "PYTHON", or
"pYThOn".
By OM PRAMOD
51
The Python Regex Handbook: Your Ultimate Cheatsheet
If you want to match parentheses as literal characters in a string, you need to escape
them with a backslash . So, if you want to match a string that contains parentheses,
you would use ( and ) in your regular expression.
 Backslash
In regular expressions, the backslash () is used as an escape character. It allows you
to match special characters that have a specific meaning in regular expressions, such
as . (dot), * (asterisk), + (plus), ? (question mark), ^ (caret), $ (dollar sign), {} (curly
braces), [] (square brackets), () (parentheses), and | (pipe). For instance, if you want
to match a literal asterisk (*), you need to escape it using a backslash (). For example,
the regular expression * will match a single asterisk. Here are some examples:
By OM PRAMOD
52
The Python Regex Handbook: Your Ultimate Cheatsheet
A In regular expressions, the sequence A is a special sequence that matches the start of the string.
It is equivalent to the caret (^) character, which also matches the start of the string. However,
unlike the caret, A does not match the start of a line in a multiline string, it only matches the start
of the entire string.
Z In regular expressions, the sequence Z is a special sequence that matches the end of the string.
It is equivalent to the dollar sign ($) character, which also matches the end of the string. However,
unlike the dollar sign, Z does not match the end of a line in a multiline string, it only matches the
end of the entire string.
b In regular expressions, the sequence b is a special sequence that matches the empty string, but
only at the beginning or end of a word. A word is a set of alphanumeric characters surrounded by
non-alphanumeric characters (such as space).
By OM PRAMOD
53
The Python Regex Handbook: Your Ultimate Cheatsheet
It's important to note that the b sequence always matches the empty string or boundary
between an alphanumeric character and a non-alphanumeric character. For instance, if you are
looking for the word "ssa", using a b special sequence like this "bssab" will not return a match
because non-alphanumeric characters do not border it on both sides.
B In regular expressions, the sequence B is a special sequence that matches the empty string, but
only at positions where one side is a word character and the other side is not a word character. A
word character is a character that can be used to form words. These include alphanumeric
characters (letters and digits) and the underscore character.
By OM PRAMOD
54
The Python Regex Handbook: Your Ultimate Cheatsheet
In regular expressions, the sequence b is a special sequence that matches the empty string, but
only at the beginning or end of a word. A word is a set of alphanumeric characters surrounded by
non-alphanumeric characters (such as space).
d In regular expressions, the sequence d is a special sequence that matches any digit from 0 to 9.
It's equivalent to the character set [0-9].
By OM PRAMOD
55
The Python Regex Handbook: Your Ultimate Cheatsheet
If you want to match a specific number of digits, you can use the d sequence with a quantifier.
For example, the regular expression d{3} will match any sequence of exactly three digits.
D In regular expressions, the sequence D is a special sequence that matches any character that is
not a digit. It's equivalent to the character set [^0-9].
If you want to match a specific number of non-digit characters, you can use the D sequence with
a quantifier. For example, the regular expression D{3} will match any sequence of exactly three
non-digit characters.
By OM PRAMOD
56
The Python Regex Handbook: Your Ultimate Cheatsheet
s In regular expressions, the sequence s is a special sequence that matches any whitespace
character. This includes spaces, tabs, line breaks, and other space-like characters.
S In regular expressions, the sequence S is a special sequence that matches any non-whitespace
character. This includes all characters that are not spaces, tabs, line breaks, and other space-like
characters.
If you want to match a specific number of non-whitespace characters, you can use the S
sequence with a quantifier. For example, the regular expression S{3} will match any sequence of
exactly three non-whitespace characters
By OM PRAMOD
57
The Python Regex Handbook: Your Ultimate Cheatsheet
w In regular expressions, the sequence w is a special sequence that matches any word character.
A word character is a character that can be used to form words. These include alphanumeric
characters (letters and digits) and the underscore character.
If you want to match a specific number of word characters, you can use the w sequence with a
quantifier. For example, the regular expression w{3} will match any sequence of exactly three
word characters.
By OM PRAMOD
58
The Python Regex Handbook: Your Ultimate Cheatsheet
W In regular expressions, the sequence W is a special sequence that matches any non-word
character. A non-word character is a character that cannot be used to form words. These include
all characters that are not alphanumeric (letters and digits) and not underscores.
By OM PRAMOD
59
The Python Regex Handbook: Your Ultimate Cheatsheet
Python RegEx Expressions Functions
re.search(pattern,
string)
By OM PRAMOD
60
The Python Regex Handbook: Your Ultimate Cheatsheet
re.findall(pattern,
string)
By OM PRAMOD
61
The Python Regex Handbook: Your Ultimate Cheatsheet
re.match(pattern,
string)
By OM PRAMOD
62
The Python Regex Handbook: Your Ultimate Cheatsheet
re.split(pattern,
string)
By OM PRAMOD
63
The Python Regex Handbook: Your Ultimate Cheatsheet
re.fullmatch(pattern,
string)
By OM PRAMOD
64
The Python Regex Handbook: Your Ultimate Cheatsheet
re.finditer(pattern,
string)
By OM PRAMOD
65
The Python Regex Handbook: Your Ultimate Cheatsheet
re.sub(pattern,
replacement, string)
By OM PRAMOD
66
The Python Regex Handbook: Your Ultimate Cheatsheet
re.escape(string)
By OM PRAMOD
67
The Python Regex Handbook: Your Ultimate Cheatsheet
re.subn()
By OM PRAMOD
68
The Python Regex Handbook: Your Ultimate Cheatsheet
re.VERBOSE
By OM PRAMOD
69
The Python Regex Handbook: Your Ultimate Cheatsheet
re.MULTILINE
By OM PRAMOD
70
The Python Regex Handbook: Your Ultimate Cheatsheet
By OM PRAMOD
71
The Python Regex Handbook: Your Ultimate Cheatsheet
SUMMARY
By OM PRAMOD
72
The Python Regex Handbook: Your Ultimate Cheatsheet
buymeacoffee.com/ompramod
https://medium.com/@ompramod9921

More Related Content

Similar to RegEx Book.pdf

Looking for Patterns
Looking for PatternsLooking for Patterns
Looking for PatternsKeith Wright
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular ExpressionsMukesh Tekwani
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressionsmussawir20
 
An Introduction to Regular expressions
An Introduction to Regular expressionsAn Introduction to Regular expressions
An Introduction to Regular expressionsYamagata Europe
 
Don't Fear the Regex - CapitalCamp/GovDays 2014
Don't Fear the Regex - CapitalCamp/GovDays 2014Don't Fear the Regex - CapitalCamp/GovDays 2014
Don't Fear the Regex - CapitalCamp/GovDays 2014Sandy Smith
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressionsBen Brumfield
 
16 Java Regex
16 Java Regex16 Java Regex
16 Java Regexwayn
 
Basta mastering regex power
Basta mastering regex powerBasta mastering regex power
Basta mastering regex powerMax Kleiner
 
Eloquent Ruby chapter 4 - Find The Right String with Regular Expression
Eloquent Ruby chapter 4 - Find The Right String with Regular ExpressionEloquent Ruby chapter 4 - Find The Right String with Regular Expression
Eloquent Ruby chapter 4 - Find The Right String with Regular ExpressionKuyseng Chhoeun
 
Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Sandy Smith
 
Don't Fear the Regex WordCamp DC 2017
Don't Fear the Regex WordCamp DC 2017Don't Fear the Regex WordCamp DC 2017
Don't Fear the Regex WordCamp DC 2017Sandy Smith
 
Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Sandy Smith
 
Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and YouJames Armes
 

Similar to RegEx Book.pdf (20)

Looking for Patterns
Looking for PatternsLooking for Patterns
Looking for Patterns
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular Expressions
 
Python - Lecture 7
Python - Lecture 7Python - Lecture 7
Python - Lecture 7
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressions
 
An Introduction to Regular expressions
An Introduction to Regular expressionsAn Introduction to Regular expressions
An Introduction to Regular expressions
 
Don't Fear the Regex - CapitalCamp/GovDays 2014
Don't Fear the Regex - CapitalCamp/GovDays 2014Don't Fear the Regex - CapitalCamp/GovDays 2014
Don't Fear the Regex - CapitalCamp/GovDays 2014
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
 
Grep Introduction
Grep IntroductionGrep Introduction
Grep Introduction
 
16 Java Regex
16 Java Regex16 Java Regex
16 Java Regex
 
2013 - Andrei Zmievski: Clínica Regex
2013 - Andrei Zmievski: Clínica Regex2013 - Andrei Zmievski: Clínica Regex
2013 - Andrei Zmievski: Clínica Regex
 
Basta mastering regex power
Basta mastering regex powerBasta mastering regex power
Basta mastering regex power
 
Eloquent Ruby chapter 4 - Find The Right String with Regular Expression
Eloquent Ruby chapter 4 - Find The Right String with Regular ExpressionEloquent Ruby chapter 4 - Find The Right String with Regular Expression
Eloquent Ruby chapter 4 - Find The Right String with Regular Expression
 
Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015
 
Don't Fear the Regex WordCamp DC 2017
Don't Fear the Regex WordCamp DC 2017Don't Fear the Regex WordCamp DC 2017
Don't Fear the Regex WordCamp DC 2017
 
Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Don't Fear the Regex LSP15
Don't Fear the Regex LSP15
 
Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and You
 

Recently uploaded

CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 

Recently uploaded (20)

CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 

RegEx Book.pdf

  • 1. Your Ultimate Cheatsheet AIML Enthusiast Om Pramod
  • 2. By OM PRAMOD 1 The Python Regex Handbook: Your Ultimate Cheatsheet Period (.)
  • 3. By OM PRAMOD 2 The Python Regex Handbook: Your Ultimate Cheatsheet * (Asterisk)
  • 4. By OM PRAMOD 3 The Python Regex Handbook: Your Ultimate Cheatsheet Caret (^)
  • 5. By OM PRAMOD 4 The Python Regex Handbook: Your Ultimate Cheatsheet $ (Dollar)
  • 6. By OM PRAMOD 5 The Python Regex Handbook: Your Ultimate Cheatsheet
  • 7. By OM PRAMOD 6 The Python Regex Handbook: Your Ultimate Cheatsheet + (Plus)
  • 8. By OM PRAMOD 7 The Python Regex Handbook: Your Ultimate Cheatsheet
  • 9. By OM PRAMOD 8 The Python Regex Handbook: Your Ultimate Cheatsheet ? (Question Mark)
  • 10. By OM PRAMOD 9 The Python Regex Handbook: Your Ultimate Cheatsheet | (Pipe)
  • 11. By OM PRAMOD 10 The Python Regex Handbook: Your Ultimate Cheatsheet () (Parentheses)
  • 12. By OM PRAMOD 11 The Python Regex Handbook: Your Ultimate Cheatsheet
  • 13. By OM PRAMOD 12 The Python Regex Handbook: Your Ultimate Cheatsheet
  • 14. By OM PRAMOD 13 The Python Regex Handbook: Your Ultimate Cheatsheet {} (Braces)
  • 15. By OM PRAMOD 14 The Python Regex Handbook: Your Ultimate Cheatsheet [] (Square Brackets)
  • 16. By OM PRAMOD 15 The Python Regex Handbook: Your Ultimate Cheatsheet
  • 17. By OM PRAMOD 16 The Python Regex Handbook: Your Ultimate Cheatsheet (Backslash) w
  • 18. By OM PRAMOD 17 The Python Regex Handbook: Your Ultimate Cheatsheet W
  • 19. By OM PRAMOD 18 The Python Regex Handbook: Your Ultimate Cheatsheet s
  • 20. By OM PRAMOD 19 The Python Regex Handbook: Your Ultimate Cheatsheet S
  • 21. By OM PRAMOD 20 The Python Regex Handbook: Your Ultimate Cheatsheet d
  • 22. By OM PRAMOD 21 The Python Regex Handbook: Your Ultimate Cheatsheet
  • 23. By OM PRAMOD 22 The Python Regex Handbook: Your Ultimate Cheatsheet D
  • 24. By OM PRAMOD 23 The Python Regex Handbook: Your Ultimate Cheatsheet b
  • 25. By OM PRAMOD 24 The Python Regex Handbook: Your Ultimate Cheatsheet
  • 26. By OM PRAMOD 25 The Python Regex Handbook: Your Ultimate Cheatsheet B
  • 27. By OM PRAMOD 26 The Python Regex Handbook: Your Ultimate Cheatsheet A
  • 28. By OM PRAMOD 27 The Python Regex Handbook: Your Ultimate Cheatsheet Z
  • 29. By OM PRAMOD 28 The Python Regex Handbook: Your Ultimate Cheatsheet n
  • 30. By OM PRAMOD 29 The Python Regex Handbook: Your Ultimate Cheatsheet t
  • 31. By OM PRAMOD 30 The Python Regex Handbook: Your Ultimate Cheatsheet [a-z]
  • 32. By OM PRAMOD 31 The Python Regex Handbook: Your Ultimate Cheatsheet [A-Z]: [arn]
  • 33. By OM PRAMOD 32 The Python Regex Handbook: Your Ultimate Cheatsheet [^arn] [a-n]
  • 34. By OM PRAMOD 33 The Python Regex Handbook: Your Ultimate Cheatsheet [^a-n]
  • 35. By OM PRAMOD 34 The Python Regex Handbook: Your Ultimate Cheatsheet [^0-3] [0123]
  • 36. By OM PRAMOD 35 The Python Regex Handbook: Your Ultimate Cheatsheet [0-9] [0-5][0-9]
  • 37. By OM PRAMOD 36 The Python Regex Handbook: Your Ultimate Cheatsheet [a-zA-Z]
  • 38. By OM PRAMOD 37 The Python Regex Handbook: Your Ultimate Cheatsheet [a-zA-Z0-9] {n}
  • 39. By OM PRAMOD 38 The Python Regex Handbook: Your Ultimate Cheatsheet {n,} {,m}: {n,m}
  • 40. By OM PRAMOD 39 The Python Regex Handbook: Your Ultimate Cheatsheet [] Square brackets In regular expressions, square brackets ([]) are used to define a character set, which is a set of characters you want to match. This can be useful when you want to match any one character from a specific set of characters. You can also use square brackets to match any character that is not in a specific set. This is done by placing a caret (^) at the start of the character set In addition to individual characters, you can also use a hyphen (-) inside square brackets to specify a range of characters. However, if you want to include a hyphen in your character set, you need to place it at the start or end of the character set. This is because the hyphen is used to denote a range in regular expressions. Placing it at the start or end ensures it is interpreted as the literal character - and not as a range specifier.
  • 41. By OM PRAMOD 40 The Python Regex Handbook: Your Ultimate Cheatsheet In some cases, you might want to match the square brackets themselves as characters. This can be done by escaping the square brackets with a backslash ().This is because square brackets have a special meaning in regular expressions, denoting a character set. By using a backslash, you’re indicating that you want to match the literal character and not use its special meaning. For instance, For example, the regular expression [ will match a single opening square bracket, and ] will match a single closing square bracket. . Period In regular expressions, the dot (.) is a special character that matches any single character except newline characters(This is an important aspect of regular expressions to keep in mind when matching across multiple lines.). This means it can represent any character from the alphabet, numbers, special characters, etc.
  • 42. By OM PRAMOD 41 The Python Regex Handbook: Your Ultimate Cheatsheet If you want to match a literal dot (.), you need to escape it using a backslash (). For example, the regular expression . will match a single dot. This is because inside a character class, the dot (.) loses its special meaning and matches a literal dot. ^ Caret In regular expressions, the caret (^) is a special character that has different meanings depending on its usage. Start of Line or String: When used at the start of a regular expression, the caret (^) represents the start of a line or a string. For example, the regular expression ^hello will match any string that starts with the word "hello". Negation in Character Sets: When used inside square brackets ([]), the caret (^) negates the set of characters. This means it will match any character that is not in the set. For example, the regular expression [^abc] will match any character that is not 'a', 'b', or 'c'. Literal Caret Character: If you want to match the actual caret (^) character, you need to escape it using a backslash (). For example, the regular expression ^ will match a single caret.
  • 43. By OM PRAMOD 42 The Python Regex Handbook: Your Ultimate Cheatsheet $ Dollar In regular expressions, the dollar sign ($) is a special character that represents the end of a line or a string. * Star In regular expressions, the asterisk (*) is a special character known as a quantifier that specifies that the preceding character or group should be matched zero or more times. This means it can match the preceding character or group any number of times, including not at all. If you want to match a literal asterisk (*), you need to escape it using a backslash (). For example, the regular expression * will match a single asterisk. This is because inside a character class, the asterisk (*) loses its special meaning and matches a literal asterisk.
  • 44. By OM PRAMOD 43 The Python Regex Handbook: Your Ultimate Cheatsheet + Plus In regular expressions, the plus sign (+) is a special character known as a quantifier that specifies that the preceding character or group should be matched one or more times. This means it can match the preceding character or group at least once, but possibly more. If you want to match a literal plus sign (+), you need to escape it using a backslash (). For example, the regular expression + will match a single plus sign. This is because inside a character class, the plus sign (+) loses its special meaning and matches a literal plus sign. This is an example of how escaping works in regular expressions. Escaping is used to treat special characters as literal characters. Inside a character class (denoted by square brackets []), the plus sign + loses its special meaning and matches a literal plus sign. For example, the regular expression [+] will match a single plus sign. This is because inside a character class, special characters lose their special meaning and are treated as literal characters. This is another important aspect of regular expressions to keep in mind.
  • 45. By OM PRAMOD 44 The Python Regex Handbook: Your Ultimate Cheatsheet ? Question Mark In regular expressions, the question mark (?) is a special character known as a quantifier that specifies that the preceding character or group should be matched zero or one times. This means it can match the preceding character or group either once or not at all. If you want to match a literal question mark (?), you need to escape it using a backslash (). For example, the regular expression ? will match a single question mark. This is because inside a character class, the question mark (?) loses its special meaning and matches a literal question mark. Similarly, inside a character class (denoted by square brackets []), most special characters lose their special meaning and are treated as literal characters. So, [?] would also match a literal question mark (?). In addition to its role as a quantifier, the question mark (?) can also be used in certain contexts to make a group optional or to apply modifiers to only part of the regular expression. Optional Grouping: You can use the question mark to make an entire
  • 46. By OM PRAMOD 45 The Python Regex Handbook: Your Ultimate Cheatsheet group optional. This is done by surrounding the part of the pattern that should be optional with parentheses (), and placing a question mark after the closing parenthesis Modifiers: The question mark can also be used to apply modifiers to only part of the regular expression. This is done by placing the modifier after a question mark inside parentheses. In regular expressions, (?i) is a mode modifier that makes the rest of the pattern case-insensitive. This means that the pattern will match regardless of whether the characters are in uppercase or lowercase. For example, the pattern (?i) abc will match abc, ABC, Abc, aBc, abC, ABc, aBC, and AbC. It’s a very useful feature when you want to match a string regardless of its case. Please note that the ?i should be enclosed in parentheses like this: (?i).
  • 47. By OM PRAMOD 46 The Python Regex Handbook: Your Ultimate Cheatsheet The (?=) syntax in regular expressions is known as a positive lookahead assertion. It is used to assert that a certain pattern is ahead in the string, but it does not consume any of the string. This means that the current position in the string remains the same after the lookahead assertion. Lookahead assertions are particularly useful when you want to match a pattern only if it's followed by another pattern, but you don't want to include the second pattern in the match. For example, consider the regular expression q(?=u)i. This expression will match a 'q' that is followed by a 'u', without making the 'u' part of the match. The positive lookahead construct is a pair of parentheses, with the opening parenthesis followed by a question mark and an equals sign. {} Braces In regular expressions, curly braces ({}) are used as quantifiers to specify the exact number of times a character or group should be matched. They are used in the format {n}, where n is the exact number of times the preceding character or group should be matched.
  • 48. By OM PRAMOD 47 The Python Regex Handbook: Your Ultimate Cheatsheet If you want to match a literal pair of curly braces ({}), you need to escape them using a backslash (). For example, the regular expression {} will match a single pair of curly braces. This is because inside a character class, the curly braces ({}) lose their special meaning and match a literal pair of curly braces. Similarly, inside a character class (denoted by square brackets []), most special characters lose their special meaning and are treated as literal characters. So, [{}] would also match a literal pair of curly braces ({}). Curly braces can also be used in the format {n,} to match the preceding character or group at least n times. For example, the regular expression a{2,} will match "aa", "aaa", "aaaa", and so on. the {,m} quantifier in regular expressions specifies that the preceding character or group should be matched at most m times. Here m is a positive integer. If the character or group appears more than m times, it will not be a match.
  • 49. By OM PRAMOD 48 The Python Regex Handbook: Your Ultimate Cheatsheet Similarly, curly braces can be used in the format {n,m} to match the preceding character or group at least n times and at most m times. For example, the regular expression a{2,3} will match "aa", "aaa" | Alternatio n In regular expressions, the pipe symbol (|) is used as an alternation operator, which is similar to the logical OR operator. It allows you to match either the pattern before the pipe or the pattern after the pipe. () Group In regular expressions, parentheses (()) are used for grouping and capturing. Grouping: Parentheses are used to group parts of a regular expression together. This allows you to apply a quantifier to the entire group or to restrict alternation to part of the regular expression. Parentheses group parts of the pattern together. This allows you to apply quantifiers to multiple characters instead of just one. For example, in the pattern (abc)+, the + applies to the entire string abc, not just the character c.
  • 50. By OM PRAMOD 49 The Python Regex Handbook: Your Ultimate Cheatsheet Capturing: Besides grouping part of a regular expression together, parentheses also create a numbered capturing group. It stores the part of the string matched by the part of the regular expression inside the parentheses.
  • 51. By OM PRAMOD 50 The Python Regex Handbook: Your Ultimate Cheatsheet The (?i) keyword in regular expressions is used to perform case-insensitive matching. When included in a regular expression, it makes the expression match the target string regardless of the case of the characters. The (?i) keyword is particularly useful when you're not sure of the exact casing of the string you're trying to match or when you want to match multiple variations of a word or phrase. It allows you to write more flexible and robust regular expressions that can handle different input formats. For example, the regular expression /python/ would only match strings that contain the word "python" in lowercase. However, if you add (?i) to the beginning of the expression, like /(?i)python/, it will match strings that contain "python" in any combination of uppercase and lowercase letters, such as "Python", "PYTHON", or "pYThOn".
  • 52. By OM PRAMOD 51 The Python Regex Handbook: Your Ultimate Cheatsheet If you want to match parentheses as literal characters in a string, you need to escape them with a backslash . So, if you want to match a string that contains parentheses, you would use ( and ) in your regular expression. Backslash In regular expressions, the backslash () is used as an escape character. It allows you to match special characters that have a specific meaning in regular expressions, such as . (dot), * (asterisk), + (plus), ? (question mark), ^ (caret), $ (dollar sign), {} (curly braces), [] (square brackets), () (parentheses), and | (pipe). For instance, if you want to match a literal asterisk (*), you need to escape it using a backslash (). For example, the regular expression * will match a single asterisk. Here are some examples:
  • 53. By OM PRAMOD 52 The Python Regex Handbook: Your Ultimate Cheatsheet A In regular expressions, the sequence A is a special sequence that matches the start of the string. It is equivalent to the caret (^) character, which also matches the start of the string. However, unlike the caret, A does not match the start of a line in a multiline string, it only matches the start of the entire string. Z In regular expressions, the sequence Z is a special sequence that matches the end of the string. It is equivalent to the dollar sign ($) character, which also matches the end of the string. However, unlike the dollar sign, Z does not match the end of a line in a multiline string, it only matches the end of the entire string. b In regular expressions, the sequence b is a special sequence that matches the empty string, but only at the beginning or end of a word. A word is a set of alphanumeric characters surrounded by non-alphanumeric characters (such as space).
  • 54. By OM PRAMOD 53 The Python Regex Handbook: Your Ultimate Cheatsheet It's important to note that the b sequence always matches the empty string or boundary between an alphanumeric character and a non-alphanumeric character. For instance, if you are looking for the word "ssa", using a b special sequence like this "bssab" will not return a match because non-alphanumeric characters do not border it on both sides. B In regular expressions, the sequence B is a special sequence that matches the empty string, but only at positions where one side is a word character and the other side is not a word character. A word character is a character that can be used to form words. These include alphanumeric characters (letters and digits) and the underscore character.
  • 55. By OM PRAMOD 54 The Python Regex Handbook: Your Ultimate Cheatsheet In regular expressions, the sequence b is a special sequence that matches the empty string, but only at the beginning or end of a word. A word is a set of alphanumeric characters surrounded by non-alphanumeric characters (such as space). d In regular expressions, the sequence d is a special sequence that matches any digit from 0 to 9. It's equivalent to the character set [0-9].
  • 56. By OM PRAMOD 55 The Python Regex Handbook: Your Ultimate Cheatsheet If you want to match a specific number of digits, you can use the d sequence with a quantifier. For example, the regular expression d{3} will match any sequence of exactly three digits. D In regular expressions, the sequence D is a special sequence that matches any character that is not a digit. It's equivalent to the character set [^0-9]. If you want to match a specific number of non-digit characters, you can use the D sequence with a quantifier. For example, the regular expression D{3} will match any sequence of exactly three non-digit characters.
  • 57. By OM PRAMOD 56 The Python Regex Handbook: Your Ultimate Cheatsheet s In regular expressions, the sequence s is a special sequence that matches any whitespace character. This includes spaces, tabs, line breaks, and other space-like characters. S In regular expressions, the sequence S is a special sequence that matches any non-whitespace character. This includes all characters that are not spaces, tabs, line breaks, and other space-like characters. If you want to match a specific number of non-whitespace characters, you can use the S sequence with a quantifier. For example, the regular expression S{3} will match any sequence of exactly three non-whitespace characters
  • 58. By OM PRAMOD 57 The Python Regex Handbook: Your Ultimate Cheatsheet w In regular expressions, the sequence w is a special sequence that matches any word character. A word character is a character that can be used to form words. These include alphanumeric characters (letters and digits) and the underscore character. If you want to match a specific number of word characters, you can use the w sequence with a quantifier. For example, the regular expression w{3} will match any sequence of exactly three word characters.
  • 59. By OM PRAMOD 58 The Python Regex Handbook: Your Ultimate Cheatsheet W In regular expressions, the sequence W is a special sequence that matches any non-word character. A non-word character is a character that cannot be used to form words. These include all characters that are not alphanumeric (letters and digits) and not underscores.
  • 60. By OM PRAMOD 59 The Python Regex Handbook: Your Ultimate Cheatsheet Python RegEx Expressions Functions re.search(pattern, string)
  • 61. By OM PRAMOD 60 The Python Regex Handbook: Your Ultimate Cheatsheet re.findall(pattern, string)
  • 62. By OM PRAMOD 61 The Python Regex Handbook: Your Ultimate Cheatsheet re.match(pattern, string)
  • 63. By OM PRAMOD 62 The Python Regex Handbook: Your Ultimate Cheatsheet re.split(pattern, string)
  • 64. By OM PRAMOD 63 The Python Regex Handbook: Your Ultimate Cheatsheet re.fullmatch(pattern, string)
  • 65. By OM PRAMOD 64 The Python Regex Handbook: Your Ultimate Cheatsheet re.finditer(pattern, string)
  • 66. By OM PRAMOD 65 The Python Regex Handbook: Your Ultimate Cheatsheet re.sub(pattern, replacement, string)
  • 67. By OM PRAMOD 66 The Python Regex Handbook: Your Ultimate Cheatsheet re.escape(string)
  • 68. By OM PRAMOD 67 The Python Regex Handbook: Your Ultimate Cheatsheet re.subn()
  • 69. By OM PRAMOD 68 The Python Regex Handbook: Your Ultimate Cheatsheet re.VERBOSE
  • 70. By OM PRAMOD 69 The Python Regex Handbook: Your Ultimate Cheatsheet re.MULTILINE
  • 71. By OM PRAMOD 70 The Python Regex Handbook: Your Ultimate Cheatsheet
  • 72. By OM PRAMOD 71 The Python Regex Handbook: Your Ultimate Cheatsheet SUMMARY
  • 73. By OM PRAMOD 72 The Python Regex Handbook: Your Ultimate Cheatsheet