SlideShare una empresa de Scribd logo
1 de 10
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

Más contenido relacionado

Destacado (7)

Croissance: les couts et les imperatifs du numerique
Croissance: les couts et les imperatifs du numeriqueCroissance: les couts et les imperatifs du numerique
Croissance: les couts et les imperatifs du numerique
 
Derechos de los niños, niñas y adolescentes
Derechos de los niños, niñas y adolescentesDerechos de los niños, niñas y adolescentes
Derechos de los niños, niñas y adolescentes
 
Presentación calidad operaciones unam octubre 2015
Presentación calidad operaciones unam octubre 2015Presentación calidad operaciones unam octubre 2015
Presentación calidad operaciones unam octubre 2015
 
The genres
The genresThe genres
The genres
 
St koyumah 1284202033
St koyumah 1284202033St koyumah 1284202033
St koyumah 1284202033
 
Maria_Rojas_Presentación
Maria_Rojas_PresentaciónMaria_Rojas_Presentación
Maria_Rojas_Presentación
 
MI PRIMER TRABAJO
MI PRIMER TRABAJOMI PRIMER TRABAJO
MI PRIMER TRABAJO
 

Similar a Regex by 131357 (12)

Automata
AutomataAutomata
Automata
 
Unit ii
Unit iiUnit ii
Unit ii
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
 
QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
 
1LECTURE 8 Regular_Expressions.ppt
1LECTURE 8 Regular_Expressions.ppt1LECTURE 8 Regular_Expressions.ppt
1LECTURE 8 Regular_Expressions.ppt
 
UNIT_-_II.docx
UNIT_-_II.docxUNIT_-_II.docx
UNIT_-_II.docx
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
Re1 (3)
Re1 (3)Re1 (3)
Re1 (3)
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2
 

Último

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 

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?