SlideShare a Scribd company logo
1 of 8
REGULAR EXPRESSIONS
by-
Atharva Solanki
Just as finite automata are used
to recognize patterns of strings, regular
expressions are used to generate patterns of
strings. A regular expression is an algebraic
formula whose value is a pattern consisting of a
set of strings, called the language of the
expression.
 Characters from the alphabet over which
the regular expression is defined.
 Variables whose values are any pattern
defined by a regular expression.
 Epsilon which denotes the empty string
containing no characters.
 Null which denotes the empty set of strings.
 Union: If R1 and R2 are regular expressions, then R1 |
R2 (also written as R1 U R2 or R1 + R2) is also a regular
expression . L(R1|R2) = L(R1) U L(R2).
 Concatenation: If R1 and R2 are regular expressions,
then R1R2 (also written as R1.R2) is also a regular
expression . L(R1R2) = L(R1) concatenated with L(R2).
 Kleene closure: If R1 is a regular expression, then
R1* (the Kleene closure of R1) is also a regular expression .
L(R1*) = epsilon U L(R1) U L(R1R1) U L(R1R1R1) U ...
 Closure has the highest precedence, followed
by concatenation, followed by union.
 The set of strings over {0,1} that end in 3 consecutive
1's.
 (0 | 1)* 111 The set of strings over {0,1} that have at
least one 1.
 0* 1 (0 | 1)* The set of strings over {0,1} that have at
most one 1.
 0* | 0* 1 0* The set of strings over {A..Z,a..z} that
contain the word "main".
 Let <letter> = A | B | ... | Z | a | b | ... | z <letter>*
main <letter>* The set of strings over {A..Z,a..z} that
contain 3 x's. <letter>* x <letter>* x <letter>* x
<letter>*
 Regular expressions and finite automata have
equivalent expressive power:
 For every regular expression R, there is a
corresponding FA that accepts the set of strings
generated by R.
 For every FA A there is a corresponding regular
expression that generates the set of strings
accepted by A.
 The proof is in two parts:
 an algorithm that, given a regular expression R,
produces an FA A such that L(A) == L(R).
 an algorithm that, given an FA A, produces a
regular expression R such that L(R) == L(A).
Regular expressions

More Related Content

What's hot

Two very short proofs of combinatorial identity - Integers 5 A18 (2005)
Two very short proofs of combinatorial identity - Integers 5 A18 (2005)Two very short proofs of combinatorial identity - Integers 5 A18 (2005)
Two very short proofs of combinatorial identity - Integers 5 A18 (2005)Roberto Anglani
 
41 interval notation and review on inequalities
41 interval notation and review on inequalities41 interval notation and review on inequalities
41 interval notation and review on inequalitiesmath126
 
Roots of real numbers and radical expressions
Roots of real numbers and radical expressionsRoots of real numbers and radical expressions
Roots of real numbers and radical expressionsJessica Garcia
 
13string in c#
13string in c#13string in c#
13string in c#Sireesh K
 
Application of HCR's Rank Formula on color property of articles
Application of HCR's Rank Formula on color property of articlesApplication of HCR's Rank Formula on color property of articles
Application of HCR's Rank Formula on color property of articlesHarish Chandra Rajpoot
 
7.6 solving logarithmic equations
7.6 solving logarithmic equations7.6 solving logarithmic equations
7.6 solving logarithmic equationsswartzje
 
Fuzzy Matching with Apache Spark
Fuzzy Matching with Apache SparkFuzzy Matching with Apache Spark
Fuzzy Matching with Apache SparkDataWorks Summit
 

What's hot (10)

Two very short proofs of combinatorial identity - Integers 5 A18 (2005)
Two very short proofs of combinatorial identity - Integers 5 A18 (2005)Two very short proofs of combinatorial identity - Integers 5 A18 (2005)
Two very short proofs of combinatorial identity - Integers 5 A18 (2005)
 
Regular languag regular set
Regular languag regular setRegular languag regular set
Regular languag regular set
 
41 interval notation and review on inequalities
41 interval notation and review on inequalities41 interval notation and review on inequalities
41 interval notation and review on inequalities
 
Roots of real numbers and radical expressions
Roots of real numbers and radical expressionsRoots of real numbers and radical expressions
Roots of real numbers and radical expressions
 
13string in c#
13string in c#13string in c#
13string in c#
 
Application of HCR's Rank Formula on color property of articles
Application of HCR's Rank Formula on color property of articlesApplication of HCR's Rank Formula on color property of articles
Application of HCR's Rank Formula on color property of articles
 
Regex posix
Regex posixRegex posix
Regex posix
 
7.6 solving logarithmic equations
7.6 solving logarithmic equations7.6 solving logarithmic equations
7.6 solving logarithmic equations
 
String functions
String functionsString functions
String functions
 
Fuzzy Matching with Apache Spark
Fuzzy Matching with Apache SparkFuzzy Matching with Apache Spark
Fuzzy Matching with Apache Spark
 

Similar to Regular expressions

Chapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfChapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfDrIsikoIsaac
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfdawod yimer
 
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdfAutomata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdfTONY562
 
Automata
AutomataAutomata
AutomataGaditek
 
Automata
AutomataAutomata
AutomataGaditek
 
theory of computation lecture 02
theory of computation lecture 02theory of computation lecture 02
theory of computation lecture 028threspecter
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxRaviAr5
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationPrafullMisra
 
Regular expression (compiler)
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)Jagjit Wilku
 

Similar to Regular expressions (20)

Chapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfChapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdf
 
Ch2 automata.pptx
Ch2 automata.pptxCh2 automata.pptx
Ch2 automata.pptx
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Regular languag regular set
Regular languag regular setRegular languag regular set
Regular languag regular set
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdfAutomata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
 
Module 1 TOC.pptx
Module 1 TOC.pptxModule 1 TOC.pptx
Module 1 TOC.pptx
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
theory of computation lecture 02
theory of computation lecture 02theory of computation lecture 02
theory of computation lecture 02
 
Regular expression (compiler)
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
 
Theory of computation
Theory of computationTheory of computation
Theory of computation
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 
regular expression
regular expressionregular expression
regular expression
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
 
QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's Classification
 
Regular expression (compiler)
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)
 

Recently uploaded

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Regular expressions

  • 2. Just as finite automata are used to recognize patterns of strings, regular expressions are used to generate patterns of strings. A regular expression is an algebraic formula whose value is a pattern consisting of a set of strings, called the language of the expression.
  • 3.  Characters from the alphabet over which the regular expression is defined.  Variables whose values are any pattern defined by a regular expression.  Epsilon which denotes the empty string containing no characters.  Null which denotes the empty set of strings.
  • 4.  Union: If R1 and R2 are regular expressions, then R1 | R2 (also written as R1 U R2 or R1 + R2) is also a regular expression . L(R1|R2) = L(R1) U L(R2).  Concatenation: If R1 and R2 are regular expressions, then R1R2 (also written as R1.R2) is also a regular expression . L(R1R2) = L(R1) concatenated with L(R2).  Kleene closure: If R1 is a regular expression, then R1* (the Kleene closure of R1) is also a regular expression . L(R1*) = epsilon U L(R1) U L(R1R1) U L(R1R1R1) U ...
  • 5.  Closure has the highest precedence, followed by concatenation, followed by union.
  • 6.  The set of strings over {0,1} that end in 3 consecutive 1's.  (0 | 1)* 111 The set of strings over {0,1} that have at least one 1.  0* 1 (0 | 1)* The set of strings over {0,1} that have at most one 1.  0* | 0* 1 0* The set of strings over {A..Z,a..z} that contain the word "main".  Let <letter> = A | B | ... | Z | a | b | ... | z <letter>* main <letter>* The set of strings over {A..Z,a..z} that contain 3 x's. <letter>* x <letter>* x <letter>* x <letter>*
  • 7.  Regular expressions and finite automata have equivalent expressive power:  For every regular expression R, there is a corresponding FA that accepts the set of strings generated by R.  For every FA A there is a corresponding regular expression that generates the set of strings accepted by A.  The proof is in two parts:  an algorithm that, given a regular expression R, produces an FA A such that L(A) == L(R).  an algorithm that, given an FA A, produces a regular expression R such that L(R) == L(A).