0% found this document useful (0 votes)
6 views

Python_RegEx_Patterns_1687630938

This document provides an overview of common regular expression (RegEx) patterns used in Python, highlighting their functionality and syntax. It covers various patterns such as '.', '*', '+', and others, along with their meanings and examples. The content aims to help users become familiar with RegEx for effective text data manipulation in Python programming.

Uploaded by

tech.mhmreddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python_RegEx_Patterns_1687630938

This document provides an overview of common regular expression (RegEx) patterns used in Python, highlighting their functionality and syntax. It covers various patterns such as '.', '*', '+', and others, along with their meanings and examples. The content aims to help users become familiar with RegEx for effective text data manipulation in Python programming.

Uploaded by

tech.mhmreddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Common Patterns used in

Python RegEx
Swipe
@shankardayalsingh
Regular expressions, or RegEx, is a powerful
tool for working with text data in Python.

They are essentially a tiny, highly specialized


programming language embedded inside Python
and made available through the re module. With
RegEx, you can define a pattern that matches
specific characters, words, or patterns within a
text.

Although the syntax of RegEx takes some


time to get used to, once you get comfortable
with it, you'll find RegEx almost indispensable in
your Python programming.

This PDF covers some common RegEx


patterns used in Python with sample codes.
Swipe @shankardayalsingh
1. ‘.’ (dot):
Matches any single character except a newline character.

2. ‘*’ (asterisk):
Matches zero or more occurrences of the preceding
character.

Swipe @shankardayalsingh
3. ‘+’ (plus):
Matches one or more occurrences of the preceding character.

4. [] (square brackets):
Matches any character within the brackets.

Swipe @shankardayalsingh
5. ‘\d’ (backslash d):
Matches any digit.

6. ‘^’ (caret):
Matches the beginning of a string.

Swipe @shankardayalsingh
7. ‘$’ (dollar sign):
Matches the end of a string.

8. ‘\w’ (backslash w):


Matches any alphanumeric character.

Swipe @shankardayalsingh
9. ‘\s’ (backslash s):
Matches any whitespace character.

10. ‘\b’ (backslash b):


Matches a word boundary.

Swipe @shankardayalsingh
11. () (parentheses):
Groups characters together and creates a capture group.

12. ‘|’ (pipe):


Matches either the pattern before or after the pipe.

Swipe @shankardayalsingh
13. {} (curly braces):
Matches a specific number of occurrences of the preceding
character.

14. ‘?’ (question mark):


Match zero or one occurrence of a character.

Swipe @shankardayalsingh
LIKE
SAVE
SHARE

Follow
@shankardayalsingh

You might also like