SlideShare a Scribd company logo
A regular expression is a pattern that describes a set of strings.
WHY?
 Regular expressions are used in many situation in computer programming.
 Majorly in search, pattern matching, parsing, filtering of results and so on.
 In lay man words, its a kind of rule which programmer tells to the computer to
understand.
 You may see this in website forms, where you are only forced to enter ONLY
numbers or ONLY characters or MINIMUM 8 characters and so on, these are
controlled by REGEX behind the screen.
 American mathematician credited for
inventing Regular Expressions in the
1950’s using a mathematic notation called
regular sets.
 Union +
 Concatenation .
 Kleene Star *
 Concatenation:
 x = 010
 y = 1101
 x.y = 010 1101
 Language Union:
 L1 = {01, 00}
 L2 = {01, 11, 010}
 L1 +L2 = {01, 00, 11, 010}
 Kleene closure
 1*={ε,1,11,111,1111,……}
(0 + 1)* All strings of 0’s and 1’s
01* 0 followed by any number 1’s
0(0 + 1)* All strings of 0’s and 1’s, beginning with a 0
(0 + 1)*1 All strings of 0’s and 1’s, ending with a 1
 Nondeterministic finite automaton with ε-moves (NFA-ε) is a further
generalization to NFA.This automaton replaces the transition function with the one
that allows the empty string ε as a possible input.The transitions without
consuming an input symbol are called ε-transitions.
8
For E1
For E2
For E1 E2
ε
ε ε
ε
9
For E1 For E2
For E1E2
ε
10
For E
For E*
ε
ε
εε
Convert a regular expression to NFA :
(ab ∪ a)*
 In DFA, for each input symbol, one can determine the state to which the machine
will move. Hence, it is called Deterministic Automaton. As it has a finite number
of states, the machine is called Deterministic Finite Machineor Deterministic
Finite Automaton.
 A Generalized Nondeterministic Finite Automaton is similar to an NFA but the
transition function takes a state and a regular expression in the alphabet instead of a
state and an alphabet element.
The idea is that in state q0 the transition to state q1 can be taken if the next input
matches the regular expression 1101.
 A generalized nondeterministic finite automaton is a 5-tuple, (Q,∑, δ, qstart, qaccept),
where
 Q is the finite set of states,
 ∑ is the input alphabet
 δ : (Q - {qaccept} x (Q - { qstart }) → R is the transition function, where R is the set of all
regular expressions over ∑
 qstart is the start state
 qaccept is the accept state
 1.Add a new start state and a new final state.
 2. Add epsi transitions to the new states.
 3. Remove 3
 4. Link between 2 and f is now b
 5. Remove 3
 6. Add a new link between 2 and 2 with bb∪a as a lop.
 7. Now link between 1 and 2 with ba.
 8. Remove 2
 9. Link 1 and f with (a∪b)(bb∪a)*b
 10. Link s and f with ((a∪b)(bb∪a)*ba)*((a∪b)(bb∪a)*b)
 This is the regular Expression from this NFA
CFG
WHAT IS CFG??
CFG MEANS CONTEXT –FREE GRAMMAR. IN FORMAL LANGUAGE THEORY, A CONTEXT-FREE GRAMMAR (CFG) IS A CERTAIN
TYPE OF FORMAL GRAMMAR: A SET OF PRODUCTION RULES THAT DESCRIBE ALL POSSIBLE STRINGS IN A GIVEN FORMAL LANGUAGE.
IN SIMPLE WORD IT’S A NOTATION OF DESCRIBING LANGUAGE.
[SOURCE : HTTPS://EN.WIKIPEDIA.ORG/WIKI/CONTEXT-FREEG_RAMMAR]
WHAT DOES CFG DO??
A CFG PROVIDES A SIMPLE AND MATHEMATICALLY PRECISE MECHANISM FOR DESCRIBING THE
METHODS BY WHICH PHRASES IN SOME NATURAL LANGUAGE ARE BUILT FROM SMALLER BLOCKS,
CAPTURING THE BLOCK STRUCTURE OF SENTENCES IN A NATURAL WAY.
CONTENTS OF DESCRIPTIONS
1. AMBIGUOUS GRAMMAR
2. DERIVATION
3. PARSE TREE
AMBIGUOUS GRAMMAR
GENERALLY REPRESENT BY ( V T P S )
VARIABLE TERMINAL PRODUCTION START SYMBOL
EXAMPLE:
S- AB
A AA
HERE ,
A = TERMINAL
V = VARIABLE
DERIVATION
TWO TYPE OF DERIVATION:
1. LEFT-MOST DERIVATION:
SAB
DERIVATION START FROM THE LEFT SIDE VARIABLE.
2. RIGHT-MOST DERIVATION:
SAB
DERIVATION START FROM THE RIGHT SIDE VARIABLE.
PARSE TREE
SAA
AA
FOR STRING AA PARSE TREE IS:
S
A A
A A
EXAMPLE OF CFG
A REGULAR EXPRESSION THAT START AND END WITH SAME SYMBOL
A(A+B)*A + B(A+B)*B +A +B +Ε
L={AA, BB, ABA, ABBA, AABA, BAAAB……..}
HERE GRAMMAR IS:
S AAA|BAB|A|B|Ε
A AA|BA|Ε
FOR STRING AABA THE DERIVATION IS:
S AAA
 AAAA
 AABAA
 AABΕAA
 AABA
PARSE TREE:
S
A
A
A
A A B Ε A
Wrote the regex library which is what Perl and Tcl
languages used for regular expressions
 PCRE
 POSIX
 BASIC & EXTENDED REGEX
 ECMA REGEX
 & LOADS more!
 RegEx flavors are not consistent in implementation
WHY USE IT?
 It makes changing large amounts of repetitive text trivial as long as you can see
patterns.
 It makes you awesome in a geeky way.
 Programming Languages: Javascript, PHP, PERL, C/C++
 Command-Line: grep, awk, sed
 Text-Editors:Vim, Emacas, Notepad++
 IDE’s: Netbeans,Visual Studio
 Standard Characters
 Letters: A to Z, a to z
 Numbers: 0 to 9
 Symbols: !, @, #, %, &, e.t.c.
 Meta Characters
 Special Characters: )(][^$.|?*+
 To use those special characters escape them with blackslash
 Matches one & only characters in a set of characters.
 [Aa] matches either ‘A’ or ‘a’
 [a-z] matches one lowercase letter among specified range
 [^Aa] matches anything but ‘A; and ‘a’
 d, [0-9] digits 0 t0 9
 w, [da-zA-Z_] alphanumeric or _
 s , [t(?:n|rn)] whitespace
 Matches any single character but the newline.
 Using a pipe | , match either the left or right side of the pattern.
 (You | Me) matches a string that contains either
 {n} Matches exactly n times
 {n,} Matches n or more times
 {n,m} Matches between n and m times
 * Same as {0,1}
 + Same as {1,}
 ? Same as {0,1}
 Matches positions instead of characters
 ^ matches beginning
 $ matches end
 b matches between token
 Positive Lookahead
 Iron(?=man) matches “Iron” if it is followed by “man”
 Negative Lookahead
 Iron(?!man) matches “iron” if it is not followed by “man”
 Positive Lookbehind
 (?<=Iron)man matches “man” if it is preceded by “Iron’
 Negative Lookbehind
 (?<!Iron)man matches “man” if it is not preceded by “Iron”
function isWeakPassword( $pwd ) {
$error = false;
if (strlen($pwd) < 8) {
$error = "Password Must be 8 Character
Long!";
}if (!preg_match("#[0-9]+#", $pwd)) {
$error = "Password must include at least
one number!";
}if (!preg_match("#[A-Z]+#", $pwd)) {
$error = "Password must include at least
one Upper Case letter!";
}
if (!preg_match("#[a-z]+#", $pwd)) {
$error = "Password must include at least
one lower case letter!";
} if(!preg_match('`[$*.,+-=@]`',$pwd))
$error = "Password must include a
symbol!";
return $error;
}
ThankYou 

More Related Content

What's hot

Regular expressions
Regular expressionsRegular expressions
Regular expressions
Shiraz316
 
Regular expression
Regular expressionRegular expression
Regular expression
Larry Nung
 
Multi dimensional arrays
Multi dimensional arraysMulti dimensional arrays
Multi dimensional arraysAseelhalees
 
Regular Expression in Compiler design
Regular Expression in Compiler designRegular Expression in Compiler design
Regular Expression in Compiler design
Riazul Islam
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
Ben Brumfield
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
Matt Casto
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
Tsegazeab Asgedom
 
Theory of Automata Lesson 02
Theory of Automata Lesson 02Theory of Automata Lesson 02
Theory of Automata Lesson 02
hamzamughal39
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ignaz Wanders
 
Closure properties
Closure propertiesClosure properties
Closure properties
Dr. ABHISHEK K PANDEY
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
Dipankar Boruah
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsRaj Gupta
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
Akhil Kaushik
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
Rajendran
 
Array data structure
Array data structureArray data structure
Array data structure
maamir farooq
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
Mukesh Tekwani
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
moazamali28
 
String matching, naive,
String matching, naive,String matching, naive,
String matching, naive,
Amit Kumar Rathi
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
Maulik Togadiya
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
Muhammed Afsal Villan
 

What's hot (20)

Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Multi dimensional arrays
Multi dimensional arraysMulti dimensional arrays
Multi dimensional arrays
 
Regular Expression in Compiler design
Regular Expression in Compiler designRegular Expression in Compiler design
Regular Expression in Compiler design
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Theory of Automata Lesson 02
Theory of Automata Lesson 02Theory of Automata Lesson 02
Theory of Automata Lesson 02
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Closure properties
Closure propertiesClosure properties
Closure properties
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
 
Array data structure
Array data structureArray data structure
Array data structure
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
String matching, naive,
String matching, naive,String matching, naive,
String matching, naive,
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 

Similar to Regular expression

Regular expressions in oracle
Regular expressions in oracleRegular expressions in oracle
Regular expressions in oracle
Logan Palanisamy
 
The Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxThe Theory of Finite Automata.pptx
The Theory of Finite Automata.pptx
ssuser039bf6
 
QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
MrRRajasekarCSE
 
Unit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressionsUnit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressions
sana mateen
 
Strings,patterns and regular expressions in perl
Strings,patterns and regular expressions in perlStrings,patterns and regular expressions in perl
Strings,patterns and regular expressions in perl
sana mateen
 
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
DrIsikoIsaac
 
Automata
AutomataAutomata
Automata
Gaditek
 
Automata
AutomataAutomata
Automata
Gaditek
 
Maxbox starter20
Maxbox starter20Maxbox starter20
Maxbox starter20
Max Kleiner
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysisraosir123
 
Lec1.pptx
Lec1.pptxLec1.pptx
Lec1.pptx
ziadk6872
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)bolovv
 
Chapter Two(1)
Chapter Two(1)Chapter Two(1)
Chapter Two(1)bolovv
 
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
TONY562
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)
Logan Palanisamy
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
VenkataRaoS1
 
compiler Design course material chapter 2
compiler Design course material chapter 2compiler Design course material chapter 2
compiler Design course material chapter 2
gadisaAdamu
 

Similar to Regular expression (20)

RegexCat
RegexCatRegexCat
RegexCat
 
Regular expressions in oracle
Regular expressions in oracleRegular expressions in oracle
Regular expressions in oracle
 
The Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxThe Theory of Finite Automata.pptx
The Theory of Finite Automata.pptx
 
QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
 
Unit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressionsUnit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressions
 
Strings,patterns and regular expressions in perl
Strings,patterns and regular expressions in perlStrings,patterns and regular expressions in perl
Strings,patterns and regular expressions in perl
 
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
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
Ch3
Ch3Ch3
Ch3
 
Maxbox starter20
Maxbox starter20Maxbox starter20
Maxbox starter20
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
Lec1.pptx
Lec1.pptxLec1.pptx
Lec1.pptx
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)
 
Chapter Two(1)
Chapter Two(1)Chapter Two(1)
Chapter Two(1)
 
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
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
 
compiler Design course material chapter 2
compiler Design course material chapter 2compiler Design course material chapter 2
compiler Design course material chapter 2
 

More from Rajon

Chat Application | RSD
Chat Application | RSDChat Application | RSD
Chat Application | RSD
Rajon
 
AND | OR |XOR | Conditional | Bi-condtional
AND | OR |XOR | Conditional | Bi-condtionalAND | OR |XOR | Conditional | Bi-condtional
AND | OR |XOR | Conditional | Bi-condtional
Rajon
 
Modern Elicitation Process
Modern Elicitation ProcessModern Elicitation Process
Modern Elicitation Process
Rajon
 
Numerical Analysis lab 4
Numerical Analysis lab 4Numerical Analysis lab 4
Numerical Analysis lab 4
Rajon
 
Pillar's of Pixel's | Project report
Pillar's of Pixel's | Project reportPillar's of Pixel's | Project report
Pillar's of Pixel's | Project report
Rajon
 
Farm Manager | Project Proposal
Farm Manager | Project ProposalFarm Manager | Project Proposal
Farm Manager | Project Proposal
Rajon
 
Pillar's of Pixel' | Project proposal
Pillar's of Pixel' | Project proposalPillar's of Pixel' | Project proposal
Pillar's of Pixel' | Project proposal
Rajon
 
Displacement addressing
Displacement addressingDisplacement addressing
Displacement addressing
Rajon
 
System Design Flow
System Design FlowSystem Design Flow
System Design Flow
Rajon
 
Backup Photos- Project Proposal
Backup Photos- Project ProposalBackup Photos- Project Proposal
Backup Photos- Project Proposal
Rajon
 
Chat Application - Requirements Analysis & Design
Chat Application - Requirements Analysis & DesignChat Application - Requirements Analysis & Design
Chat Application - Requirements Analysis & Design
Rajon
 
Canvas
CanvasCanvas
Canvas
Rajon
 
Chat Application FAQ
Chat Application FAQChat Application FAQ
Chat Application FAQ
Rajon
 
Presentation On Software Testing Bug Life Cycle
Presentation On Software Testing Bug Life CyclePresentation On Software Testing Bug Life Cycle
Presentation On Software Testing Bug Life Cycle
Rajon
 
Chat Application [Full Documentation]
Chat Application [Full Documentation]Chat Application [Full Documentation]
Chat Application [Full Documentation]
Rajon
 
Presentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project PlanningPresentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project Planning
Rajon
 

More from Rajon (16)

Chat Application | RSD
Chat Application | RSDChat Application | RSD
Chat Application | RSD
 
AND | OR |XOR | Conditional | Bi-condtional
AND | OR |XOR | Conditional | Bi-condtionalAND | OR |XOR | Conditional | Bi-condtional
AND | OR |XOR | Conditional | Bi-condtional
 
Modern Elicitation Process
Modern Elicitation ProcessModern Elicitation Process
Modern Elicitation Process
 
Numerical Analysis lab 4
Numerical Analysis lab 4Numerical Analysis lab 4
Numerical Analysis lab 4
 
Pillar's of Pixel's | Project report
Pillar's of Pixel's | Project reportPillar's of Pixel's | Project report
Pillar's of Pixel's | Project report
 
Farm Manager | Project Proposal
Farm Manager | Project ProposalFarm Manager | Project Proposal
Farm Manager | Project Proposal
 
Pillar's of Pixel' | Project proposal
Pillar's of Pixel' | Project proposalPillar's of Pixel' | Project proposal
Pillar's of Pixel' | Project proposal
 
Displacement addressing
Displacement addressingDisplacement addressing
Displacement addressing
 
System Design Flow
System Design FlowSystem Design Flow
System Design Flow
 
Backup Photos- Project Proposal
Backup Photos- Project ProposalBackup Photos- Project Proposal
Backup Photos- Project Proposal
 
Chat Application - Requirements Analysis & Design
Chat Application - Requirements Analysis & DesignChat Application - Requirements Analysis & Design
Chat Application - Requirements Analysis & Design
 
Canvas
CanvasCanvas
Canvas
 
Chat Application FAQ
Chat Application FAQChat Application FAQ
Chat Application FAQ
 
Presentation On Software Testing Bug Life Cycle
Presentation On Software Testing Bug Life CyclePresentation On Software Testing Bug Life Cycle
Presentation On Software Testing Bug Life Cycle
 
Chat Application [Full Documentation]
Chat Application [Full Documentation]Chat Application [Full Documentation]
Chat Application [Full Documentation]
 
Presentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project PlanningPresentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project Planning
 

Recently uploaded

Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Access Innovations, Inc.
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
IP ServerOne
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
faizulhassanfaiz1670
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
OWASP Beja
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
eCommerce Institute
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Orkestra
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
Vladimir Samoylov
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
gharris9
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
Access Innovations, Inc.
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 

Recently uploaded (17)

Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 

Regular expression

  • 1.
  • 2. A regular expression is a pattern that describes a set of strings. WHY?  Regular expressions are used in many situation in computer programming.  Majorly in search, pattern matching, parsing, filtering of results and so on.  In lay man words, its a kind of rule which programmer tells to the computer to understand.  You may see this in website forms, where you are only forced to enter ONLY numbers or ONLY characters or MINIMUM 8 characters and so on, these are controlled by REGEX behind the screen.
  • 3.  American mathematician credited for inventing Regular Expressions in the 1950’s using a mathematic notation called regular sets.
  • 4.  Union +  Concatenation .  Kleene Star *
  • 5.  Concatenation:  x = 010  y = 1101  x.y = 010 1101  Language Union:  L1 = {01, 00}  L2 = {01, 11, 010}  L1 +L2 = {01, 00, 11, 010}  Kleene closure  1*={ε,1,11,111,1111,……}
  • 6. (0 + 1)* All strings of 0’s and 1’s 01* 0 followed by any number 1’s 0(0 + 1)* All strings of 0’s and 1’s, beginning with a 0 (0 + 1)*1 All strings of 0’s and 1’s, ending with a 1
  • 7.  Nondeterministic finite automaton with ε-moves (NFA-ε) is a further generalization to NFA.This automaton replaces the transition function with the one that allows the empty string ε as a possible input.The transitions without consuming an input symbol are called ε-transitions.
  • 8. 8 For E1 For E2 For E1 E2 ε ε ε ε
  • 9. 9 For E1 For E2 For E1E2 ε
  • 11. Convert a regular expression to NFA : (ab ∪ a)*
  • 12.  In DFA, for each input symbol, one can determine the state to which the machine will move. Hence, it is called Deterministic Automaton. As it has a finite number of states, the machine is called Deterministic Finite Machineor Deterministic Finite Automaton.
  • 13.  A Generalized Nondeterministic Finite Automaton is similar to an NFA but the transition function takes a state and a regular expression in the alphabet instead of a state and an alphabet element. The idea is that in state q0 the transition to state q1 can be taken if the next input matches the regular expression 1101.
  • 14.  A generalized nondeterministic finite automaton is a 5-tuple, (Q,∑, δ, qstart, qaccept), where  Q is the finite set of states,  ∑ is the input alphabet  δ : (Q - {qaccept} x (Q - { qstart }) → R is the transition function, where R is the set of all regular expressions over ∑  qstart is the start state  qaccept is the accept state
  • 15.
  • 16.  1.Add a new start state and a new final state.  2. Add epsi transitions to the new states.  3. Remove 3  4. Link between 2 and f is now b  5. Remove 3  6. Add a new link between 2 and 2 with bb∪a as a lop.  7. Now link between 1 and 2 with ba.  8. Remove 2  9. Link 1 and f with (a∪b)(bb∪a)*b  10. Link s and f with ((a∪b)(bb∪a)*ba)*((a∪b)(bb∪a)*b)  This is the regular Expression from this NFA
  • 17. CFG WHAT IS CFG?? CFG MEANS CONTEXT –FREE GRAMMAR. IN FORMAL LANGUAGE THEORY, A CONTEXT-FREE GRAMMAR (CFG) IS A CERTAIN TYPE OF FORMAL GRAMMAR: A SET OF PRODUCTION RULES THAT DESCRIBE ALL POSSIBLE STRINGS IN A GIVEN FORMAL LANGUAGE. IN SIMPLE WORD IT’S A NOTATION OF DESCRIBING LANGUAGE. [SOURCE : HTTPS://EN.WIKIPEDIA.ORG/WIKI/CONTEXT-FREEG_RAMMAR]
  • 18. WHAT DOES CFG DO?? A CFG PROVIDES A SIMPLE AND MATHEMATICALLY PRECISE MECHANISM FOR DESCRIBING THE METHODS BY WHICH PHRASES IN SOME NATURAL LANGUAGE ARE BUILT FROM SMALLER BLOCKS, CAPTURING THE BLOCK STRUCTURE OF SENTENCES IN A NATURAL WAY.
  • 19. CONTENTS OF DESCRIPTIONS 1. AMBIGUOUS GRAMMAR 2. DERIVATION 3. PARSE TREE
  • 20. AMBIGUOUS GRAMMAR GENERALLY REPRESENT BY ( V T P S ) VARIABLE TERMINAL PRODUCTION START SYMBOL EXAMPLE: S- AB A AA HERE , A = TERMINAL V = VARIABLE
  • 21. DERIVATION TWO TYPE OF DERIVATION: 1. LEFT-MOST DERIVATION: SAB DERIVATION START FROM THE LEFT SIDE VARIABLE. 2. RIGHT-MOST DERIVATION: SAB DERIVATION START FROM THE RIGHT SIDE VARIABLE.
  • 22. PARSE TREE SAA AA FOR STRING AA PARSE TREE IS: S A A A A
  • 23. EXAMPLE OF CFG A REGULAR EXPRESSION THAT START AND END WITH SAME SYMBOL A(A+B)*A + B(A+B)*B +A +B +Ε L={AA, BB, ABA, ABBA, AABA, BAAAB……..} HERE GRAMMAR IS: S AAA|BAB|A|B|Ε A AA|BA|Ε FOR STRING AABA THE DERIVATION IS: S AAA  AAAA  AABAA  AABΕAA  AABA
  • 25. Wrote the regex library which is what Perl and Tcl languages used for regular expressions
  • 26.  PCRE  POSIX  BASIC & EXTENDED REGEX  ECMA REGEX  & LOADS more!
  • 27.  RegEx flavors are not consistent in implementation WHY USE IT?  It makes changing large amounts of repetitive text trivial as long as you can see patterns.  It makes you awesome in a geeky way.
  • 28.  Programming Languages: Javascript, PHP, PERL, C/C++  Command-Line: grep, awk, sed  Text-Editors:Vim, Emacas, Notepad++  IDE’s: Netbeans,Visual Studio
  • 29.  Standard Characters  Letters: A to Z, a to z  Numbers: 0 to 9  Symbols: !, @, #, %, &, e.t.c.  Meta Characters  Special Characters: )(][^$.|?*+  To use those special characters escape them with blackslash
  • 30.  Matches one & only characters in a set of characters.  [Aa] matches either ‘A’ or ‘a’  [a-z] matches one lowercase letter among specified range  [^Aa] matches anything but ‘A; and ‘a’
  • 31.  d, [0-9] digits 0 t0 9  w, [da-zA-Z_] alphanumeric or _  s , [t(?:n|rn)] whitespace
  • 32.  Matches any single character but the newline.
  • 33.  Using a pipe | , match either the left or right side of the pattern.  (You | Me) matches a string that contains either
  • 34.  {n} Matches exactly n times  {n,} Matches n or more times  {n,m} Matches between n and m times  * Same as {0,1}  + Same as {1,}  ? Same as {0,1}
  • 35.  Matches positions instead of characters  ^ matches beginning  $ matches end  b matches between token
  • 36.  Positive Lookahead  Iron(?=man) matches “Iron” if it is followed by “man”  Negative Lookahead  Iron(?!man) matches “iron” if it is not followed by “man”  Positive Lookbehind  (?<=Iron)man matches “man” if it is preceded by “Iron’  Negative Lookbehind  (?<!Iron)man matches “man” if it is not preceded by “Iron”
  • 37. function isWeakPassword( $pwd ) { $error = false; if (strlen($pwd) < 8) { $error = "Password Must be 8 Character Long!"; }if (!preg_match("#[0-9]+#", $pwd)) { $error = "Password must include at least one number!"; }if (!preg_match("#[A-Z]+#", $pwd)) { $error = "Password must include at least one Upper Case letter!"; } if (!preg_match("#[a-z]+#", $pwd)) { $error = "Password must include at least one lower case letter!"; } if(!preg_match('`[$*.,+-=@]`',$pwd)) $error = "Password must include a symbol!"; return $error; }
  • 38.
  • 39.