SlideShare une entreprise Scribd logo
1  sur  20
Regular expression (RE)
- crash course
door Daniel Genis, Byte Internet
Regex - What is a regular expression
- A mini program accepts or rejects a string.
- Can be used to parse data out of strings
Regex - Why regular expressions?
PRO
● Parsing is fast O(n) + NFA generation time
○ NFA generation time is a one time penalty
○ For a RE of size m we can build an NFA at a cost of
O(2^m)
● Useful for validating string input
● Can be used in all Programming languages
○ Even in MySQL or other databases. But please
please don’t use RE in database queries :-)
● Useful for fetching/parsing data out of strings
● Very powerful tool. A real swiss army knife!
Regex - When to avoid RE?
CONS
● Regexes are a mini programs in themselves
● They can become very complex
● Some people argue regexes should always be avoided
● They are not very human readable
● Not everyone is comfortable with RE
● DFA must be created/compiled initially
Regex - Getting a feel
Two dummy examples
^aap?$
a()?p+p
Real world example:
DB_BACKUP_REGEX = "^[a-zA-Z0-9_-]+_((d|-)+_(d|-
)+)_UTC.sql.gz$"
Regex - Semantic buildingblocks
‘.’ == Matches any character except a newline
‘^’ == Matches the start of the string
‘$’ == Matches the end of a string
‘*’ == Causes the resulting RE to match 0 or more repetitions
‘+’ == Causes the resulting RE to match 1 or more repetitions
‘?’ == Causes the resulting RE to match 0 or 1 repetitions
Regex - basics - Which string matches?
Regex: ^a(ab)*b$
Strings:
aaab
aabb
ab
abbb
aababb
_aabb _ == whitespace
aabb_
Regex - basics - ^ () * $
Regex: ^a(ab)*b$
Strings:
aaab
aabb
ab
abbb
aababb
_aabb _ == whitespace
aabb_
Regex - basics - ^ () * $
Regex: ^a(ab)*b$
Strings:
aaab
aabb
ab
abbb
aababb
_aabb
aabb_
Regex - basics - Which string matches?
Regex: aa+b*b$ old regex: ^a(ab)*b$
Strings:
aaab
aabb
ab
abbb
aababb
_aabb _ == whitespace
aabb_
Regex - basics - Which string matches?
Regex: aa+b*b$ old regex: ^a(ab)*b$
Strings:
aaab
aabb
ab
abbb
aababa
_aabb
aabb_
Regex - basics - Which string matches?
Regex: aa+b*b$ old regex: ^a(ab)*b$
Strings:
aaab
aabb
ab
abbb
aababa
_aabb
aabb_
Regex - some more buildingblocks
[a-zA-Z0-9] == w
Matches 1 character a-z or A-Z or 0-9.
and is the same as w
d == [0-9]
Matches 1 number
d{5}
Matches 5 numbers
Regex - bad practical example
import re
data = “2014-06-04 20:00”
# How do we parse this to integers?
regex = “^(d{4})-(d{2})-(d{2}) (d{2}):(d{2})”
regex2 = “(d+)-(d+)-(d+) (d+):(d+)” # Works too!
re.findall(regex, data)
# returns
Regex - regex DFA
regex2 =
“(d+)-(d+)-(d+) (d+):(d+)”
Regex - stuff we didn’t cover! :D
Regex can get very very complicated.
Just to give you some idea:
- Lookahead assertion
(?=...)
Matches if ... matches next, but doesn’t consume any of the
string. This is called a lookahead assertion. For example, Isaac
(?=Asimov) will match 'Isaac ' only if it’s followed by 'Asimov'.
For example: (Isaac (?=Asimov))|(Banaan)
Will match ‘Isaac Asimov’ or ‘Banaan’
Regex - stuff we didn’t cover! :D
- Greedy vs Non-Greedy
‘*’, ‘+’, ‘?’ are greedy quanitifiers. They will match as much
as possible to obtain a match.
Non greedy quanitfiers will match as little as possible to
achieve a match.
Adding a ‘?’ makes the above quantifiers non-greedy
‘*?’, ‘+?’, ‘??’
We’ll skip these 2 for now :-)
- Positive lookbehind assertion
Greedy vs Non-greedy example
string = abbb
regex = ab+?
matches = abbb
regex = ab+
matches = abbb
regex = ab+?$
matches = abbb
Vragen
?
Regex - Usefull tools!
Regex -> NFA/DFA converter
http://hackingoff.com/compilers/regular-expression-to-nfa-dfa
Testing regexes yourself
http://www.pythonregex.com/

Contenu connexe

Tendances

The last decade of RWiki and lazy me.
The last decade of RWiki and lazy me.The last decade of RWiki and lazy me.
The last decade of RWiki and lazy me.
mseki
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python Programmers
Vsevolod Dyomkin
 
Gaucheで本を作る
Gaucheで本を作るGaucheで本を作る
Gaucheで本を作る
guest7a66b8
 

Tendances (10)

Elastic @Deezer
Elastic @DeezerElastic @Deezer
Elastic @Deezer
 
The last decade of RWiki and lazy me.
The last decade of RWiki and lazy me.The last decade of RWiki and lazy me.
The last decade of RWiki and lazy me.
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...
 
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetDConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
 
Parallel computing with GPars
Parallel computing with GParsParallel computing with GPars
Parallel computing with GPars
 
Ruby & GCs (QConSP 2014)
Ruby & GCs (QConSP 2014)Ruby & GCs (QConSP 2014)
Ruby & GCs (QConSP 2014)
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python Programmers
 
Swift and the BigData
Swift and the BigDataSwift and the BigData
Swift and the BigData
 
Gaucheで本を作る
Gaucheで本を作るGaucheで本を作る
Gaucheで本を作る
 
A Very Brief Intro to Golang
A Very Brief Intro to GolangA Very Brief Intro to Golang
A Very Brief Intro to Golang
 

En vedette (6)

Google Webmasters Tools
Google Webmasters ToolsGoogle Webmasters Tools
Google Webmasters Tools
 
Beaumotica.com & Magento 2 - Meet Magento 2016
Beaumotica.com & Magento 2 -  Meet Magento 2016Beaumotica.com & Magento 2 -  Meet Magento 2016
Beaumotica.com & Magento 2 - Meet Magento 2016
 
Hackers traced - Meet Magento 2016
Hackers traced -  Meet Magento 2016Hackers traced -  Meet Magento 2016
Hackers traced - Meet Magento 2016
 
Presentatie snelheid ecl
Presentatie snelheid eclPresentatie snelheid ecl
Presentatie snelheid ecl
 
Workshop New Relic - juni 2015
Workshop New Relic - juni 2015Workshop New Relic - juni 2015
Workshop New Relic - juni 2015
 
Magento 2 performance - a benchmark
Magento 2 performance - a benchmarkMagento 2 performance - a benchmark
Magento 2 performance - a benchmark
 

Similaire à APMG juni 2014 - Regular Expression

27.2.9 lab regular expression tutorial
27.2.9 lab   regular expression tutorial27.2.9 lab   regular expression tutorial
27.2.9 lab regular expression tutorial
Freddy Buenaño
 

Similaire à APMG juni 2014 - Regular Expression (20)

Bioinformatica p2-p3-introduction
Bioinformatica p2-p3-introductionBioinformatica p2-p3-introduction
Bioinformatica p2-p3-introduction
 
Regexes in .NET
Regexes in .NETRegexes in .NET
Regexes in .NET
 
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekingeBioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
 
CL-NLP
CL-NLPCL-NLP
CL-NLP
 
New features in abap
New features in abapNew features in abap
New features in abap
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
 
Regular expression for everyone
Regular expression for everyoneRegular expression for everyone
Regular expression for everyone
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
Perly Parsing with Regexp::Grammars
Perly Parsing with Regexp::GrammarsPerly Parsing with Regexp::Grammars
Perly Parsing with Regexp::Grammars
 
27.2.9 lab regular expression tutorial
27.2.9 lab   regular expression tutorial27.2.9 lab   regular expression tutorial
27.2.9 lab regular expression tutorial
 
lab4_php
lab4_phplab4_php
lab4_php
 
lab4_php
lab4_phplab4_php
lab4_php
 
Bioinformatics p2-p3-perl-regexes v2014
Bioinformatics p2-p3-perl-regexes v2014Bioinformatics p2-p3-perl-regexes v2014
Bioinformatics p2-p3-perl-regexes v2014
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
 
/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i
/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i
/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i
 
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
 
User biglm
User biglmUser biglm
User biglm
 
shellScriptAlt.pptx
shellScriptAlt.pptxshellScriptAlt.pptx
shellScriptAlt.pptx
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 

Plus de Byte

Joomladagen 2014 - Google Tag Manager
Joomladagen 2014 - Google Tag ManagerJoomladagen 2014 - Google Tag Manager
Joomladagen 2014 - Google Tag Manager
Byte
 
Presentatie MUG 27 juni 2013 - Graphite/New Relic
Presentatie MUG 27 juni 2013 - Graphite/New RelicPresentatie MUG 27 juni 2013 - Graphite/New Relic
Presentatie MUG 27 juni 2013 - Graphite/New Relic
Byte
 
Mm13 nl presentatie byte
Mm13 nl presentatie byteMm13 nl presentatie byte
Mm13 nl presentatie byte
Byte
 

Plus de Byte (17)

Hypernode Pitch @ Meet Magento 2014
Hypernode Pitch @ Meet Magento 2014Hypernode Pitch @ Meet Magento 2014
Hypernode Pitch @ Meet Magento 2014
 
Joomladagen 2014 - Google Tag Manager
Joomladagen 2014 - Google Tag ManagerJoomladagen 2014 - Google Tag Manager
Joomladagen 2014 - Google Tag Manager
 
Hexagonal Design - Maarten van Schaik
Hexagonal Design - Maarten van SchaikHexagonal Design - Maarten van Schaik
Hexagonal Design - Maarten van Schaik
 
Exception Handling in Python - Rik van Achterberg & Tim Muller
Exception Handling in Python - Rik van Achterberg & Tim MullerException Handling in Python - Rik van Achterberg & Tim Muller
Exception Handling in Python - Rik van Achterberg & Tim Muller
 
Presentatie MUG 27 juni 2013 - Graphite/New Relic
Presentatie MUG 27 juni 2013 - Graphite/New RelicPresentatie MUG 27 juni 2013 - Graphite/New Relic
Presentatie MUG 27 juni 2013 - Graphite/New Relic
 
Mm13 nl presentatie byte
Mm13 nl presentatie byteMm13 nl presentatie byte
Mm13 nl presentatie byte
 
Site gehacked... hoe op te lossen?
 Site gehacked... hoe op te lossen? Site gehacked... hoe op te lossen?
Site gehacked... hoe op te lossen?
 
Varnish & Magento
Varnish & MagentoVarnish & Magento
Varnish & Magento
 
Redis - Magento User Group
Redis - Magento User GroupRedis - Magento User Group
Redis - Magento User Group
 
Help! My site has been hacked!
Help! My site has been hacked!Help! My site has been hacked!
Help! My site has been hacked!
 
Byte hackpreventie
Byte hackpreventieByte hackpreventie
Byte hackpreventie
 
Magento Speed Analysis - Meet Magento 2012
Magento Speed Analysis - Meet Magento 2012Magento Speed Analysis - Meet Magento 2012
Magento Speed Analysis - Meet Magento 2012
 
Hosting & Onderhoud Joomladagen 2012
Hosting & Onderhoud Joomladagen 2012Hosting & Onderhoud Joomladagen 2012
Hosting & Onderhoud Joomladagen 2012
 
10 Joomla vragen - Joomladagen 2010
10 Joomla vragen - Joomladagen 201010 Joomla vragen - Joomladagen 2010
10 Joomla vragen - Joomladagen 2010
 
Magento Hosting, Performance & Stabiliteit - Meet Magento 2011
Magento Hosting, Performance & Stabiliteit - Meet Magento 2011Magento Hosting, Performance & Stabiliteit - Meet Magento 2011
Magento Hosting, Performance & Stabiliteit - Meet Magento 2011
 
Google analytics - Joomladagen2012
Google analytics - Joomladagen2012Google analytics - Joomladagen2012
Google analytics - Joomladagen2012
 
Magento Mobile - Byte Seminar
Magento Mobile - Byte SeminarMagento Mobile - Byte Seminar
Magento Mobile - Byte Seminar
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

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
 
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...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

APMG juni 2014 - Regular Expression

  • 1. Regular expression (RE) - crash course door Daniel Genis, Byte Internet
  • 2. Regex - What is a regular expression - A mini program accepts or rejects a string. - Can be used to parse data out of strings
  • 3. Regex - Why regular expressions? PRO ● Parsing is fast O(n) + NFA generation time ○ NFA generation time is a one time penalty ○ For a RE of size m we can build an NFA at a cost of O(2^m) ● Useful for validating string input ● Can be used in all Programming languages ○ Even in MySQL or other databases. But please please don’t use RE in database queries :-) ● Useful for fetching/parsing data out of strings ● Very powerful tool. A real swiss army knife!
  • 4. Regex - When to avoid RE? CONS ● Regexes are a mini programs in themselves ● They can become very complex ● Some people argue regexes should always be avoided ● They are not very human readable ● Not everyone is comfortable with RE ● DFA must be created/compiled initially
  • 5. Regex - Getting a feel Two dummy examples ^aap?$ a()?p+p Real world example: DB_BACKUP_REGEX = "^[a-zA-Z0-9_-]+_((d|-)+_(d|- )+)_UTC.sql.gz$"
  • 6. Regex - Semantic buildingblocks ‘.’ == Matches any character except a newline ‘^’ == Matches the start of the string ‘$’ == Matches the end of a string ‘*’ == Causes the resulting RE to match 0 or more repetitions ‘+’ == Causes the resulting RE to match 1 or more repetitions ‘?’ == Causes the resulting RE to match 0 or 1 repetitions
  • 7. Regex - basics - Which string matches? Regex: ^a(ab)*b$ Strings: aaab aabb ab abbb aababb _aabb _ == whitespace aabb_
  • 8. Regex - basics - ^ () * $ Regex: ^a(ab)*b$ Strings: aaab aabb ab abbb aababb _aabb _ == whitespace aabb_
  • 9. Regex - basics - ^ () * $ Regex: ^a(ab)*b$ Strings: aaab aabb ab abbb aababb _aabb aabb_
  • 10. Regex - basics - Which string matches? Regex: aa+b*b$ old regex: ^a(ab)*b$ Strings: aaab aabb ab abbb aababb _aabb _ == whitespace aabb_
  • 11. Regex - basics - Which string matches? Regex: aa+b*b$ old regex: ^a(ab)*b$ Strings: aaab aabb ab abbb aababa _aabb aabb_
  • 12. Regex - basics - Which string matches? Regex: aa+b*b$ old regex: ^a(ab)*b$ Strings: aaab aabb ab abbb aababa _aabb aabb_
  • 13. Regex - some more buildingblocks [a-zA-Z0-9] == w Matches 1 character a-z or A-Z or 0-9. and is the same as w d == [0-9] Matches 1 number d{5} Matches 5 numbers
  • 14. Regex - bad practical example import re data = “2014-06-04 20:00” # How do we parse this to integers? regex = “^(d{4})-(d{2})-(d{2}) (d{2}):(d{2})” regex2 = “(d+)-(d+)-(d+) (d+):(d+)” # Works too! re.findall(regex, data) # returns
  • 15. Regex - regex DFA regex2 = “(d+)-(d+)-(d+) (d+):(d+)”
  • 16. Regex - stuff we didn’t cover! :D Regex can get very very complicated. Just to give you some idea: - Lookahead assertion (?=...) Matches if ... matches next, but doesn’t consume any of the string. This is called a lookahead assertion. For example, Isaac (?=Asimov) will match 'Isaac ' only if it’s followed by 'Asimov'. For example: (Isaac (?=Asimov))|(Banaan) Will match ‘Isaac Asimov’ or ‘Banaan’
  • 17. Regex - stuff we didn’t cover! :D - Greedy vs Non-Greedy ‘*’, ‘+’, ‘?’ are greedy quanitifiers. They will match as much as possible to obtain a match. Non greedy quanitfiers will match as little as possible to achieve a match. Adding a ‘?’ makes the above quantifiers non-greedy ‘*?’, ‘+?’, ‘??’ We’ll skip these 2 for now :-) - Positive lookbehind assertion
  • 18. Greedy vs Non-greedy example string = abbb regex = ab+? matches = abbb regex = ab+ matches = abbb regex = ab+?$ matches = abbb
  • 20. Regex - Usefull tools! Regex -> NFA/DFA converter http://hackingoff.com/compilers/regular-expression-to-nfa-dfa Testing regexes yourself http://www.pythonregex.com/