SlideShare a Scribd company logo
1 of 13
Regular Expressions
A Python regular expression is a sequence of metacharacters that define
a search pattern. We use these patterns in a string-searching algorithm
to "find" or "find and replace" on strings
The match Function
This function attempts to match RE pattern to string with optional flags.
Here is the syntax for this function −
Search, findall()
• The re.search() method takes a regular expression pattern and a
string and searches for that pattern within the string. If the search is
successful, search() returns a match object or None otherwise
• findall() is probably the single most powerful function in the re
module. Above we used re.search() to find the first match for a
pattern. findall() finds *all* the matches and returns them as a list of
strings, with each string representing one match.
• Findall()
• Search()
• Split()
• Sub()
• Match Objects
• Start90
• Span()
• String()
• Import re
• str=“Ramakrishna Reddy”
• x=re.findall(“R”,str)
• Print(x)
• Import re
• Str=“ ”
• X=re.serach(“xyz”,str)
• Print(x)
• Print(x.start())
• Print(x.span(1))
• Print(x.string)
• X=re.split(“rama”,str)
• Re.split(“s”,str)
• Re.split(“ “,str)
• Re.split(“”,str)
• X=re.sub(“R”,”S”,str)
• []-Returns a match if string contains pattern
• ^- starts eith given pattern
• $-ends
• .-any char except new line
• *-zero or more occurances
• +-one or more occurances
• {}-specifies no.of occurances
• /-special occurances
• d-digits
• D-without digits
• w-str contains word characters
• W-doesn’t
• s-spaces
• S-doesn’t spaces
• import re
• str="Ramakrishna Reddy"
• res=re.findall("[a]",str)
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("^Reddy",str)#Starts with name...
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("Rama$",str)#Last with name...
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("Rama...",str)#Number of characters Last
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("...sh",str)#Front of characters
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("R*",str)#Zero or more occurances
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad"
• res=re.findall("...b",str1)#Front of characters
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend"
• res=re.findall("ie*",str1)#Front of characters
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend"
• res=re.findall("r{2}",str1)#Excact Occurances
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend"
• res=re.findall("s",str1)#with spaces S also
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend1244"
• res=re.findall("d",str1)#with spaces D also
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend 1244"
• res=re.findall("W",str1)#with spaces W also Withoput having any characters
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("[a]",str)
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("^Reddy",str)#Starts with name...
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("Rama$",str)#Last with name...
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("Rama...",str)#Number of characters Last
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("...sh",str)#Front of characters
• print(res)
• import re
• str="Ramakrishna Reddy"
• res=re.findall("R*",str)#Zero or more occurances
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad"
• res=re.findall("...b",str1)#Front of characters
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend"
• res=re.findall("ie*",str1)#Front of characters
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend"
• res=re.findall("r{2}",str1)#Excact Occurances
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend"
• res=re.findall("s",str1)#with spaces S also
• print(res)
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend1244"
• res=re.findall("d",str1)#with spaces D also
• print(res)
• '''
• import re
• str="Ramakrishna Reddy"
• str1="Hyderabad friend 1234"
• res=re.findall("{123}",str)
• print(res)

More Related Content

Similar to Python Regular Expressions Guide

Similar to Python Regular Expressions Guide (20)

P3 2017 python_regexes
P3 2017 python_regexesP3 2017 python_regexes
P3 2017 python_regexes
 
regex.pptx
regex.pptxregex.pptx
regex.pptx
 
Python - Lecture 7
Python - Lecture 7Python - Lecture 7
Python - Lecture 7
 
R Functions.pptx
R Functions.pptxR Functions.pptx
R Functions.pptx
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
 
Pythonlearn-11-Regex.pptx
Pythonlearn-11-Regex.pptxPythonlearn-11-Regex.pptx
Pythonlearn-11-Regex.pptx
 
Python advanced 2. regular expression in python
Python advanced 2. regular expression in pythonPython advanced 2. regular expression in python
Python advanced 2. regular expression in python
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
 
Python String rstrip() Method.pdf
Python String rstrip() Method.pdfPython String rstrip() Method.pdf
Python String rstrip() Method.pdf
 
P3 2018 python_regexes
P3 2018 python_regexesP3 2018 python_regexes
P3 2018 python_regexes
 
Regular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular ExpressionsRegular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular Expressions
 
ACP-arrays.pptx
ACP-arrays.pptxACP-arrays.pptx
ACP-arrays.pptx
 
Regular expressions using Python
Regular expressions using PythonRegular expressions using Python
Regular expressions using Python
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
Php pattern matching
Php pattern matchingPhp pattern matching
Php pattern matching
 
Python : Functions
Python : FunctionsPython : Functions
Python : Functions
 
Python (regular expression)
Python (regular expression)Python (regular expression)
Python (regular expression)
 
11. using regular expressions with oracle database
11. using regular expressions with oracle database11. using regular expressions with oracle database
11. using regular expressions with oracle database
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational model
 
stringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfstringsinpython-181122100212.pdf
stringsinpython-181122100212.pdf
 

More from Ramakrishna Reddy Bijjam

Arrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptxArrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptxRamakrishna Reddy Bijjam
 
Python With MongoDB in advanced Python.pptx
Python With MongoDB in advanced Python.pptxPython With MongoDB in advanced Python.pptx
Python With MongoDB in advanced Python.pptxRamakrishna Reddy Bijjam
 
Pointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptxPointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptxRamakrishna Reddy Bijjam
 
Certinity Factor and Dempster-shafer theory .pptx
Certinity Factor and Dempster-shafer theory .pptxCertinity Factor and Dempster-shafer theory .pptx
Certinity Factor and Dempster-shafer theory .pptxRamakrishna Reddy Bijjam
 
Auxiliary Memory in computer Architecture.pptx
Auxiliary Memory in computer Architecture.pptxAuxiliary Memory in computer Architecture.pptx
Auxiliary Memory in computer Architecture.pptxRamakrishna Reddy Bijjam
 

More from Ramakrishna Reddy Bijjam (20)

Arrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptxArrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptx
 
Auxiliary, Cache and Virtual memory.pptx
Auxiliary, Cache and Virtual memory.pptxAuxiliary, Cache and Virtual memory.pptx
Auxiliary, Cache and Virtual memory.pptx
 
Python With MongoDB in advanced Python.pptx
Python With MongoDB in advanced Python.pptxPython With MongoDB in advanced Python.pptx
Python With MongoDB in advanced Python.pptx
 
Pointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptxPointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptx
 
Certinity Factor and Dempster-shafer theory .pptx
Certinity Factor and Dempster-shafer theory .pptxCertinity Factor and Dempster-shafer theory .pptx
Certinity Factor and Dempster-shafer theory .pptx
 
Auxiliary Memory in computer Architecture.pptx
Auxiliary Memory in computer Architecture.pptxAuxiliary Memory in computer Architecture.pptx
Auxiliary Memory in computer Architecture.pptx
 
Random Forest Decision Tree.pptx
Random Forest Decision Tree.pptxRandom Forest Decision Tree.pptx
Random Forest Decision Tree.pptx
 
K Means Clustering in ML.pptx
K Means Clustering in ML.pptxK Means Clustering in ML.pptx
K Means Clustering in ML.pptx
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
 
Python With MongoDB.pptx
Python With MongoDB.pptxPython With MongoDB.pptx
Python With MongoDB.pptx
 
Python with MySql.pptx
Python with MySql.pptxPython with MySql.pptx
Python with MySql.pptx
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdfPYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
 
BInary file Operations.pptx
BInary file Operations.pptxBInary file Operations.pptx
BInary file Operations.pptx
 
Data Science in Python.pptx
Data Science in Python.pptxData Science in Python.pptx
Data Science in Python.pptx
 
CSV JSON and XML files in Python.pptx
CSV JSON and XML files in Python.pptxCSV JSON and XML files in Python.pptx
CSV JSON and XML files in Python.pptx
 
HTML files in python.pptx
HTML files in python.pptxHTML files in python.pptx
HTML files in python.pptx
 
datareprersentation 1.pptx
datareprersentation 1.pptxdatareprersentation 1.pptx
datareprersentation 1.pptx
 
Apriori.pptx
Apriori.pptxApriori.pptx
Apriori.pptx
 
Eclat.pptx
Eclat.pptxEclat.pptx
Eclat.pptx
 
Time Series.pptx
Time Series.pptxTime Series.pptx
Time Series.pptx
 

Recently uploaded

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Python Regular Expressions Guide

  • 1. Regular Expressions A Python regular expression is a sequence of metacharacters that define a search pattern. We use these patterns in a string-searching algorithm to "find" or "find and replace" on strings The match Function This function attempts to match RE pattern to string with optional flags. Here is the syntax for this function −
  • 2. Search, findall() • The re.search() method takes a regular expression pattern and a string and searches for that pattern within the string. If the search is successful, search() returns a match object or None otherwise • findall() is probably the single most powerful function in the re module. Above we used re.search() to find the first match for a pattern. findall() finds *all* the matches and returns them as a list of strings, with each string representing one match.
  • 3. • Findall() • Search() • Split() • Sub() • Match Objects • Start90 • Span() • String()
  • 4. • Import re • str=“Ramakrishna Reddy” • x=re.findall(“R”,str) • Print(x) • Import re • Str=“ ” • X=re.serach(“xyz”,str) • Print(x)
  • 5. • Print(x.start()) • Print(x.span(1)) • Print(x.string) • X=re.split(“rama”,str) • Re.split(“s”,str) • Re.split(“ “,str) • Re.split(“”,str) • X=re.sub(“R”,”S”,str)
  • 6. • []-Returns a match if string contains pattern • ^- starts eith given pattern • $-ends • .-any char except new line • *-zero or more occurances • +-one or more occurances • {}-specifies no.of occurances • /-special occurances
  • 7. • d-digits • D-without digits • w-str contains word characters • W-doesn’t • s-spaces • S-doesn’t spaces
  • 8. • import re • str="Ramakrishna Reddy" • res=re.findall("[a]",str) • print(res) • import re • str="Ramakrishna Reddy" • res=re.findall("^Reddy",str)#Starts with name... • print(res) • import re • str="Ramakrishna Reddy" • res=re.findall("Rama$",str)#Last with name... • print(res) • import re • str="Ramakrishna Reddy" • res=re.findall("Rama...",str)#Number of characters Last • print(res)
  • 9. • import re • str="Ramakrishna Reddy" • res=re.findall("...sh",str)#Front of characters • print(res) • import re • str="Ramakrishna Reddy" • res=re.findall("R*",str)#Zero or more occurances • print(res) • import re • str="Ramakrishna Reddy" • str1="Hyderabad" • res=re.findall("...b",str1)#Front of characters • print(res) • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend" • res=re.findall("ie*",str1)#Front of characters • print(res)
  • 10. • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend" • res=re.findall("r{2}",str1)#Excact Occurances • print(res) • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend" • res=re.findall("s",str1)#with spaces S also • print(res) • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend1244" • res=re.findall("d",str1)#with spaces D also • print(res) • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend 1244" • res=re.findall("W",str1)#with spaces W also Withoput having any characters • print(res)
  • 11. • import re • str="Ramakrishna Reddy" • res=re.findall("[a]",str) • print(res) • import re • str="Ramakrishna Reddy" • res=re.findall("^Reddy",str)#Starts with name... • print(res) • import re • str="Ramakrishna Reddy" • res=re.findall("Rama$",str)#Last with name... • print(res) • import re • str="Ramakrishna Reddy" • res=re.findall("Rama...",str)#Number of characters Last • print(res) • import re • str="Ramakrishna Reddy" • res=re.findall("...sh",str)#Front of characters • print(res)
  • 12. • import re • str="Ramakrishna Reddy" • res=re.findall("R*",str)#Zero or more occurances • print(res) • import re • str="Ramakrishna Reddy" • str1="Hyderabad" • res=re.findall("...b",str1)#Front of characters • print(res) • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend" • res=re.findall("ie*",str1)#Front of characters • print(res) • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend" • res=re.findall("r{2}",str1)#Excact Occurances • print(res)
  • 13. • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend" • res=re.findall("s",str1)#with spaces S also • print(res) • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend1244" • res=re.findall("d",str1)#with spaces D also • print(res) • ''' • import re • str="Ramakrishna Reddy" • str1="Hyderabad friend 1234" • res=re.findall("{123}",str) • print(res)