REGULAR EXPRESSIONS
Junaid Lodhi
Roll # 131357
Air University Pakistan
WHY TO STUDY REGULAR
EXPRESSION?
WHAT IS REGULAR EXPRESSION?
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.
This regular expression describes Canadian postal codes
/^[A-Z][0-9][A-Z] [0-9][A-Z][0-9]$/
Any language accepted by the Finite Automata can be
represented by Regular Expression
OPERATORS USED IN REGULAR
EXPRESSIONS
I. 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).
II. 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).
III. 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 ...
NOTE:
Closure has the highest precedence, followed by concatenation,
EXAMPLES OF REGULAR
EXPRESSION
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>*
EXAMPLES CONTINUED
Set of EVEN Length String
Regular expression can be made as
EXAMPLES CONTINUED
Set of ODD Length String
Regular expression can be made as
EXAMPLE CONTINUED
Set of Strings Divisible by 3
Regular expression can be made as
PRACTICE QUESTION
Congruent to 2 mod 3
What can be the Regular Expression?
Regex by 131357

More Related Content

PDF
28805ip
PDF
Naver D2_Soccer Quick
PPTX
Employee Motivation
PPT
5.3.redes poa 2008-(julio_a_diciembre_de_2008)
PDF
SG Premium Preview Conference 2016
PPTX
Diferencias entre U.S. GAAP, IFRS y NIIF
PDF
RV 2015: America's Affordable Housing Crisis: The Role of Transit by Steve He...
PPTX
Syntax directed-translation
28805ip
Naver D2_Soccer Quick
Employee Motivation
5.3.redes poa 2008-(julio_a_diciembre_de_2008)
SG Premium Preview Conference 2016
Diferencias entre U.S. GAAP, IFRS y NIIF
RV 2015: America's Affordable Housing Crisis: The Role of Transit by Steve He...
Syntax directed-translation

Viewers also liked (7)

PDF
Croissance: les couts et les imperatifs du numerique
PPT
Derechos de los niños, niñas y adolescentes
PPT
Presentación calidad operaciones unam octubre 2015
PPT
The genres
PPTX
St koyumah 1284202033
PDF
Maria_Rojas_Presentación
PDF
MI PRIMER TRABAJO
Croissance: les couts et les imperatifs du numerique
Derechos de los niños, niñas y adolescentes
Presentación calidad operaciones unam octubre 2015
The genres
St koyumah 1284202033
Maria_Rojas_Presentación
MI PRIMER TRABAJO
Ad

Similar to Regex by 131357 (20)

PPTX
Regular expressions
PPTX
13000120020_A.pptx
PPTX
Automata theory -RE to NFA-ε
PPTX
Regular Expressions here we have .pptx
PPTX
Regular expressions
PPTX
AUTOMATA AUTOMATA Automata4Chapter3.pptx
PDF
Regular Expression
PPT
jhiu ghfpovypoqwytpboyvetpqotybpo8uvb[O8YBTE-8V
PDF
RegularExpressions.pdf
PPTX
Regular expression
PPT
Regular_Expresssions_pptsforreference.ppt
PPT
Regular expressions
PPTX
fullunit2-220307090026 (1) theory of computation.pptx
PPTX
[Compilers23] Lexical Analysis – Scanning Part I.pptx
PPT
Regular expressions-Theory of computation
PDF
Flat unit 2
DOCX
UNIT_-_II.docx
PPTX
Mod 2_RegularExpressions.pptx
PPTX
Chapter Two - Regular Expression and Regular languages.pptx
PPT
4_Regular_Expressionssssssssssassssss.ppt
Regular expressions
13000120020_A.pptx
Automata theory -RE to NFA-ε
Regular Expressions here we have .pptx
Regular expressions
AUTOMATA AUTOMATA Automata4Chapter3.pptx
Regular Expression
jhiu ghfpovypoqwytpboyvetpqotybpo8uvb[O8YBTE-8V
RegularExpressions.pdf
Regular expression
Regular_Expresssions_pptsforreference.ppt
Regular expressions
fullunit2-220307090026 (1) theory of computation.pptx
[Compilers23] Lexical Analysis – Scanning Part I.pptx
Regular expressions-Theory of computation
Flat unit 2
UNIT_-_II.docx
Mod 2_RegularExpressions.pptx
Chapter Two - Regular Expression and Regular languages.pptx
4_Regular_Expressionssssssssssassssss.ppt
Ad

Recently uploaded (20)

PPTX
Petroleum Refining & Petrochemicals.pptx
PDF
Applications of Equal_Area_Criterion.pdf
PPTX
Information Storage and Retrieval Techniques Unit III
PPTX
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
PPTX
Management Information system : MIS-e-Business Systems.pptx
PDF
First part_B-Image Processing - 1 of 2).pdf
PPTX
PRASUNET_20240614003_231416_0000[1].pptx
PPTX
Module 8- Technological and Communication Skills.pptx
PPTX
mechattonicsand iotwith sensor and actuator
PPTX
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
PDF
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
Cryptography and Network Security-Module-I.pdf
PDF
Computer organization and architecuture Digital Notes....pdf
PPTX
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
PPTX
Software Engineering and software moduleing
PPTX
Principal presentation for NAAC (1).pptx
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PDF
Computer System Architecture 3rd Edition-M Morris Mano.pdf
PDF
Java Basics-Introduction and program control
Petroleum Refining & Petrochemicals.pptx
Applications of Equal_Area_Criterion.pdf
Information Storage and Retrieval Techniques Unit III
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
Management Information system : MIS-e-Business Systems.pptx
First part_B-Image Processing - 1 of 2).pdf
PRASUNET_20240614003_231416_0000[1].pptx
Module 8- Technological and Communication Skills.pptx
mechattonicsand iotwith sensor and actuator
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Cryptography and Network Security-Module-I.pdf
Computer organization and architecuture Digital Notes....pdf
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
Software Engineering and software moduleing
Principal presentation for NAAC (1).pptx
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
Computer System Architecture 3rd Edition-M Morris Mano.pdf
Java Basics-Introduction and program control

Regex by 131357

  • 1. REGULAR EXPRESSIONS Junaid Lodhi Roll # 131357 Air University Pakistan
  • 2. WHY TO STUDY REGULAR EXPRESSION?
  • 3. WHAT IS REGULAR EXPRESSION? 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. This regular expression describes Canadian postal codes /^[A-Z][0-9][A-Z] [0-9][A-Z][0-9]$/ Any language accepted by the Finite Automata can be represented by Regular Expression
  • 4. OPERATORS USED IN REGULAR EXPRESSIONS I. 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). II. 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). III. 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 ... NOTE: Closure has the highest precedence, followed by concatenation,
  • 5. EXAMPLES OF REGULAR EXPRESSION 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>*
  • 6. EXAMPLES CONTINUED Set of EVEN Length String Regular expression can be made as
  • 7. EXAMPLES CONTINUED Set of ODD Length String Regular expression can be made as
  • 8. EXAMPLE CONTINUED Set of Strings Divisible by 3 Regular expression can be made as
  • 9. PRACTICE QUESTION Congruent to 2 mod 3 What can be the Regular Expression?