SlideShare a Scribd company logo
Regular Expressions

   How do they work
Several important Facts
1. Everything in computing was discovered in
one form or another in the 70-80’s and was
probably thought about during the 60’s.
2. The easiest way to become a great computer
engineer in the 80’s was to work for Bell Labs
and have a beard.
Back to the subject at hand
What are regular expressions?
From Wikipedia:
In computing, a regular expression provides a
concise and flexible means to "match" (specify
and recognize) strings of text, such as particular
characters, words, or patterns of characters.
Common abbreviations for "regular expression"
include regex and regexp.
Why do we need regular expressions
         (in programming)
Many reasons but most of them are in their base
finding strings in text .
Preferably without reading it

^(?("")(""[^""]+?""@)|(([0-9a-z]((.(?!.))|[-
!#$%&'*+/=?^`{}|~w])*)(?<=[0-9a-
z])@))(?([)([(d{1,3}.){3}d{1,3}])|(([0-9a-z][-
w]*[0-9a-z]*.)+[a-z0-9]{2,17}))$

^(?=.*[^a-zA-Z])(?=.*[a-z])(?=.*[A-Z])S{8,}$
Regular Expressions Syntax
            meta characters
 Grouping
     . – match any other character
     [ ] – grouping, match single character that is inside the group
     [^ ] – grouping, match single character that is not inside the group
     ( ) – sub expression, in Perl can be recalled later from special variables
 Quantifier
     {m,n} –specifies that the character/sub expression before need to be matched
      at least m times and no more than n times
     * - derived from Kleene star in formal logic, matches 0 or more amount of the
      character before it.
     ? –matches zero or one of the preceding elements
     + - derived from Kleene cross in formal logic, matches 1 or more of the
      character before it.
 Location
     ^ - Marking start of line
     $ - Marking end of line
Regular Expressions Syntax
               Character groups
 [:alpha:] - Any alphabetical character - [A-Za-z]
 [:alnum:] - Any alphanumeric character - [A-Za-z0-9]
 [:ascii:] - Any character in the ASCII character set.[:blank:] - A GNU
  extension, equal to a space or a horizontal tab ("t")
 [:cntrl:] - Any control character
 [:digit:] - Any decimal digit - [0-9], equivalent to "d“
 [:graph:] - Any printable character, excluding a space
 [:lower:] - Any lowercase character - [a-z]
 [:print:] - Any printable character, including a space
 [:punct:] - Any graphical character excluding "word" characters
 [:space:] - Any whitespace character. "s" plus the vertical tab ("cK")
 [:upper:] - Any uppercase character - [A-Z]
 [:word:] - A Perl extension - [A-Za-z0-9_], equivalent to "w“
 [:xdigit:] - Any hexadecimal digit - [0-9a-fA-F].
What is a regular expression engine
A regular expression engine is a program that takes
a set of constraints specified in a mini-
language, and then applies those constraints to a
target string, and determines whether or not the
string satisfies the constraints.

In less grandiose terms, the first part of the job is to
turn a pattern into something the computer can
efficiently use to find the matching point in the
string, and the second part is performing the search
itself.
Famous Regex Engines
Part 2
How the Perl Regex engine works
• Unlike the army only two steps
  – Compilation
     • Parsing (Size, Construction)
     • Peep-hole optimization and analysis
  – Execution
     • Start position and no-match optimizations
     • Program execution
DFA
DFA
NFA
 Equal in strength to DFA
            Smaller in size
Ken Thompson
Thompson NFA method
• In 1968 Thompson wrote an article on how to
  convert a regular expression to still unnamed
  automata (NFA)
• The article included code to explain the point
Thompson NFA method
1. Check the regex and inject . For concat action
a(b|c)*d
2. Convert to reverse polish notation
abc|*.d.
Thompson NFA method cont.
Check single character

                                      OR
        char

                                      exp
                                      exp
                  Kleene star


                                exp
Thompson NFA method cont.
• 3.Build the NFA

                        B
       A
                        C


                    D
Problems for regex
• NLP

• Unicode vs. ASCII
Some examples of Regex
• ([^s]+(.(?i)(jpg|png|gif|bmp))$)
   – Match file with specific extentions
• ^(https?://)?([da-z.-]+).([a-z.]{2,6})([/w
  .-]*)*/?$
   – Match URL
• /^#?([a-f0-9]{6}|[a-f0-9]{3})$/
   – Match a hex value
• [ -~]
   – An interesting one.

More Related Content

What's hot

Asynchronous javascript
 Asynchronous javascript Asynchronous javascript
Asynchronous javascript
Eman Mohamed
 
Json
JsonJson
Asynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesAsynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & Promises
Hùng Nguyễn Huy
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
Chetan Gadodia
 
Introducing Regular Expressions
Introducing Regular ExpressionsIntroducing Regular Expressions
Introducing Regular Expressions
Neha Jain
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
shah zeb
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
Maulik Togadiya
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ratnakar Mikkili
 
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
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
Bipul Roy Bpl
 
Regex - Regular Expression Basics
Regex - Regular Expression BasicsRegex - Regular Expression Basics
Regex - Regular Expression Basics
Eterna Han Tsai
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
Subhas Malik
 
Advanced regular expressions
Advanced regular expressionsAdvanced regular expressions
Advanced regular expressions
Neha Jain
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ивелин Кирилов
 
Node.js & Express.js Unleashed
Node.js & Express.js UnleashedNode.js & Express.js Unleashed
Node.js & Express.js Unleashed
Elewayte
 
Web services SOAP
Web services SOAPWeb services SOAP
Web services SOAP
princeirfancivil
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
kanikkk
 
Finaal application on regular expression
Finaal application on regular expressionFinaal application on regular expression
Finaal application on regular expression
Gagan019
 
LeetCode Solutions In Java .pdf
LeetCode Solutions In Java .pdfLeetCode Solutions In Java .pdf
LeetCode Solutions In Java .pdf
zupsezekno
 
openCypher: Introducing subqueries
openCypher: Introducing subqueriesopenCypher: Introducing subqueries
openCypher: Introducing subqueries
openCypher
 

What's hot (20)

Asynchronous javascript
 Asynchronous javascript Asynchronous javascript
Asynchronous javascript
 
Json
JsonJson
Json
 
Asynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesAsynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & Promises
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
 
Introducing Regular Expressions
Introducing Regular ExpressionsIntroducing Regular Expressions
Introducing Regular Expressions
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Regular expressions
Regular expressionsRegular expressions
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
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Regex - Regular Expression Basics
Regex - Regular Expression BasicsRegex - Regular Expression Basics
Regex - Regular Expression Basics
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 
Advanced regular expressions
Advanced regular expressionsAdvanced regular expressions
Advanced regular expressions
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Node.js & Express.js Unleashed
Node.js & Express.js UnleashedNode.js & Express.js Unleashed
Node.js & Express.js Unleashed
 
Web services SOAP
Web services SOAPWeb services SOAP
Web services SOAP
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
 
Finaal application on regular expression
Finaal application on regular expressionFinaal application on regular expression
Finaal application on regular expression
 
LeetCode Solutions In Java .pdf
LeetCode Solutions In Java .pdfLeetCode Solutions In Java .pdf
LeetCode Solutions In Java .pdf
 
openCypher: Introducing subqueries
openCypher: Introducing subqueriesopenCypher: Introducing subqueries
openCypher: Introducing subqueries
 

Viewers also liked

Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
Marina Santini
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ignaz Wanders
 
Regular Expressions 101
Regular Expressions 101Regular Expressions 101
Regular Expressions 101Raj Rajandran
 
Overlay automata and algorithms for fast and scalable regular expression matc...
Overlay automata and algorithms for fast and scalable regular expression matc...Overlay automata and algorithms for fast and scalable regular expression matc...
Overlay automata and algorithms for fast and scalable regular expression matc...
Shakas Technologies
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
Niek Schmoller
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
Mahzad Zahedi
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
Iffat Anjum
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
Shiraz316
 
Field Extractions: Making Regex Your Buddy
Field Extractions: Making Regex Your BuddyField Extractions: Making Regex Your Buddy
Field Extractions: Making Regex Your Buddy
Michael Wilde
 
Theory of computing pdf
Theory of computing pdfTheory of computing pdf
Theory of computing pdf
Dilouar Hossain
 
Finite State Automata
Finite State AutomataFinite State Automata
Finite State Automata
孟賢 施
 
Optimization of dfa
Optimization of dfaOptimization of dfa
Optimization of dfa
Kiran Acharya
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
Matt Casto
 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfa
Abdul Aziz
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
Animesh Chaturvedi
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
Mukesh Tekwani
 

Viewers also liked (18)

Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular Expressions 101
Regular Expressions 101Regular Expressions 101
Regular Expressions 101
 
Overlay automata and algorithms for fast and scalable regular expression matc...
Overlay automata and algorithms for fast and scalable regular expression matc...Overlay automata and algorithms for fast and scalable regular expression matc...
Overlay automata and algorithms for fast and scalable regular expression matc...
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Tests
TestsTests
Tests
 
Lecture2 B
Lecture2 BLecture2 B
Lecture2 B
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Field Extractions: Making Regex Your Buddy
Field Extractions: Making Regex Your BuddyField Extractions: Making Regex Your Buddy
Field Extractions: Making Regex Your Buddy
 
Theory of computing pdf
Theory of computing pdfTheory of computing pdf
Theory of computing pdf
 
Finite State Automata
Finite State AutomataFinite State Automata
Finite State Automata
 
Optimization of dfa
Optimization of dfaOptimization of dfa
Optimization of dfa
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfa
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 

Similar to Regular expressions

Introduction To Regex in Lasso 8.5
Introduction To Regex in Lasso 8.5Introduction To Regex in Lasso 8.5
Introduction To Regex in Lasso 8.5
bilcorry
 
Regular expressions and php
Regular expressions and phpRegular expressions and php
Regular expressions and php
David Stockton
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Chia-Chi Chang
 
Quick start reg ex
Quick start reg exQuick start reg ex
Quick start reg ex
V krishnamoorthy
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
Ahmed El-Arabawy
 
Regular Expressions 2007
Regular Expressions 2007Regular Expressions 2007
Regular Expressions 2007
Geoffrey Dunn
 
Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and YouJames Armes
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrepTri Truong
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptx
SreeLaya9
 
P3 2018 python_regexes
P3 2018 python_regexesP3 2018 python_regexes
P3 2018 python_regexes
Prof. Wim Van Criekinge
 
P3 2017 python_regexes
P3 2017 python_regexesP3 2017 python_regexes
P3 2017 python_regexes
Prof. Wim Van Criekinge
 
Regular expression for everyone
Regular expression for everyoneRegular expression for everyone
Regular expression for everyone
Sanjeev Kumar Jaiswal
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
Appili Vamsi Krishna
 
Using Regular Expressions and Staying Sane
Using Regular Expressions and Staying SaneUsing Regular Expressions and Staying Sane
Using Regular Expressions and Staying Sane
Carl Brown
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
Software Guru
 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf
ssusere19c741
 

Similar to Regular expressions (20)

Introduction To Regex in Lasso 8.5
Introduction To Regex in Lasso 8.5Introduction To Regex in Lasso 8.5
Introduction To Regex in Lasso 8.5
 
Regular expressions and php
Regular expressions and phpRegular expressions and php
Regular expressions and php
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)
 
Quick start reg ex
Quick start reg exQuick start reg ex
Quick start reg ex
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
 
Regular Expressions 2007
Regular Expressions 2007Regular Expressions 2007
Regular Expressions 2007
 
Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and You
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptx
 
P3 2018 python_regexes
P3 2018 python_regexesP3 2018 python_regexes
P3 2018 python_regexes
 
2.regular expressions
2.regular expressions2.regular expressions
2.regular expressions
 
Lexicalanalyzer
LexicalanalyzerLexicalanalyzer
Lexicalanalyzer
 
Lexicalanalyzer
LexicalanalyzerLexicalanalyzer
Lexicalanalyzer
 
P3 2017 python_regexes
P3 2017 python_regexesP3 2017 python_regexes
P3 2017 python_regexes
 
Regular expression for everyone
Regular expression for everyoneRegular expression for everyone
Regular expression for everyone
 
Bioinformatica p2-p3-introduction
Bioinformatica p2-p3-introductionBioinformatica p2-p3-introduction
Bioinformatica p2-p3-introduction
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
Using Regular Expressions and Staying Sane
Using Regular Expressions and Staying SaneUsing Regular Expressions and Staying Sane
Using Regular Expressions and Staying Sane
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf
 

Recently uploaded

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 

Recently uploaded (20)

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 

Regular expressions

  • 1. Regular Expressions How do they work
  • 2. Several important Facts 1. Everything in computing was discovered in one form or another in the 70-80’s and was probably thought about during the 60’s. 2. The easiest way to become a great computer engineer in the 80’s was to work for Bell Labs and have a beard.
  • 3. Back to the subject at hand
  • 4. What are regular expressions? From Wikipedia: In computing, a regular expression provides a concise and flexible means to "match" (specify and recognize) strings of text, such as particular characters, words, or patterns of characters. Common abbreviations for "regular expression" include regex and regexp.
  • 5. Why do we need regular expressions (in programming) Many reasons but most of them are in their base finding strings in text . Preferably without reading it ^(?("")(""[^""]+?""@)|(([0-9a-z]((.(?!.))|[- !#$%&'*+/=?^`{}|~w])*)(?<=[0-9a- z])@))(?([)([(d{1,3}.){3}d{1,3}])|(([0-9a-z][- w]*[0-9a-z]*.)+[a-z0-9]{2,17}))$ ^(?=.*[^a-zA-Z])(?=.*[a-z])(?=.*[A-Z])S{8,}$
  • 6. Regular Expressions Syntax meta characters  Grouping  . – match any other character  [ ] – grouping, match single character that is inside the group  [^ ] – grouping, match single character that is not inside the group  ( ) – sub expression, in Perl can be recalled later from special variables  Quantifier  {m,n} –specifies that the character/sub expression before need to be matched at least m times and no more than n times  * - derived from Kleene star in formal logic, matches 0 or more amount of the character before it.  ? –matches zero or one of the preceding elements  + - derived from Kleene cross in formal logic, matches 1 or more of the character before it.  Location  ^ - Marking start of line  $ - Marking end of line
  • 7. Regular Expressions Syntax Character groups  [:alpha:] - Any alphabetical character - [A-Za-z]  [:alnum:] - Any alphanumeric character - [A-Za-z0-9]  [:ascii:] - Any character in the ASCII character set.[:blank:] - A GNU extension, equal to a space or a horizontal tab ("t")  [:cntrl:] - Any control character  [:digit:] - Any decimal digit - [0-9], equivalent to "d“  [:graph:] - Any printable character, excluding a space  [:lower:] - Any lowercase character - [a-z]  [:print:] - Any printable character, including a space  [:punct:] - Any graphical character excluding "word" characters  [:space:] - Any whitespace character. "s" plus the vertical tab ("cK")  [:upper:] - Any uppercase character - [A-Z]  [:word:] - A Perl extension - [A-Za-z0-9_], equivalent to "w“  [:xdigit:] - Any hexadecimal digit - [0-9a-fA-F].
  • 8. What is a regular expression engine A regular expression engine is a program that takes a set of constraints specified in a mini- language, and then applies those constraints to a target string, and determines whether or not the string satisfies the constraints. In less grandiose terms, the first part of the job is to turn a pattern into something the computer can efficiently use to find the matching point in the string, and the second part is performing the search itself.
  • 11. How the Perl Regex engine works • Unlike the army only two steps – Compilation • Parsing (Size, Construction) • Peep-hole optimization and analysis – Execution • Start position and no-match optimizations • Program execution
  • 12. DFA
  • 13. DFA
  • 14. NFA Equal in strength to DFA Smaller in size
  • 16. Thompson NFA method • In 1968 Thompson wrote an article on how to convert a regular expression to still unnamed automata (NFA) • The article included code to explain the point
  • 17. Thompson NFA method 1. Check the regex and inject . For concat action a(b|c)*d 2. Convert to reverse polish notation abc|*.d.
  • 18. Thompson NFA method cont. Check single character OR char exp exp Kleene star exp
  • 19. Thompson NFA method cont. • 3.Build the NFA B A C D
  • 20. Problems for regex • NLP • Unicode vs. ASCII
  • 21. Some examples of Regex • ([^s]+(.(?i)(jpg|png|gif|bmp))$) – Match file with specific extentions • ^(https?://)?([da-z.-]+).([a-z.]{2,6})([/w .-]*)*/?$ – Match URL • /^#?([a-f0-9]{6}|[a-f0-9]{3})$/ – Match a hex value • [ -~] – An interesting one.

Editor's Notes

  1. Where they worked on MULTICS which later became unix
  2. From XKCD
  3. The first is for email from MSDN the second is for a password of 8 characters with atleast one lowercase upper case and other symbol
  4. This is from the POSIX specification
  5. Again those are the POSIX groups which are not implemented everywhere the examples are for Perl regex
  6. Camel for Perl, Japaneas for Onigurama (Devil Chariot), Henry Spencers picture, PCRE logo, google for RE2 and a gnu for the GNU REGEX
  7. In compiler theory, peephole optimization is a kind of optimization performed over a very small set of instructions in a segment of generated code. The set is called a &quot;peephole&quot; or a &quot;window&quot;. It works by recognising sets of instructions that can be replaced by shorter or faster set of instructions.The execution is including other algorithms like Bayer-Moore and other ways to shorten execution timeFunctions – compilationReg() for parsingReg_branch() Reg_piece()Reg_atom()Reg_tail()Study_chunk() for optimizationFunctions – ExecutionRe_intuit_start() – for starting locationsReg_try()Regmatch()
  8. Not the department of foreign affairs
  9. Accepts the language of all numbers ends with 10 or 01
  10. NFA’s transition table for the regex (l|e)*n?(i|e)el*
  11. Thompson on the left and ritchy on the rightThompson invented B helped inventing CAlso created worked on QED and ed, and invented regular expressionsHelped develop utf8 and the go language
  12. The original article included algol code for the IBM mainframe and was implanted in QED editor
  13. Reverse polish notation is used to remove ambiguity and make it easier to work with stack
  14. Natural language processing is becoming common due to computer speed and massive amounts of data, using statistical tools.UNICODE VS ASCII is a problem for developer due to characters that might be cought as the same while being different
  15. Notice it doesn’t use the xdigit which is not supported in all engines