SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
Regular Expressions
Part 1: Basic Building Blocks
What is a regular
expression?
Simple, an expression used regularly!
/ah/
Yes that is a regular expression!
You don’t believe me, try http://rubular.com/r/31xqIzPmPe
/aah/
Wonder how you’ll match
/aaaaaaaa...h/
Repetition Token
Token Property Regex Example Test String
{m, n} Match exact
occurrences of a
character/token
a{1,3}h ah, aah, aaah, aaaah,
h, ha, aha
? Matches 0 or 1
occurrence of a
token
a?h ah, aah, aaah, aaaah,
h, ha, aha
+ Matches 1 or more
occurrence of a
token
a+h ah, aah, aaah, aaaah,
h, ha, aha
* Matches 0 or more
occurrence of a
token
a*h ah, aah, aaah, aaaah,
h, ha, aha
Repetition Token
Token Property Regex Example Test String
{m, n} Match exact
occurrences of a
character/token
a{1,3}h ah, aah, aaah, aaaah,
h, ha, haaha
? Matches 0 or 1
occurrence of a
token
a?h ah, aah, aaah, aaaah,
h, ha, haaha
+ Matches 1 or more
occurrence of a
token
a+h ah, aah, aaah, aaaah,
h, ha, haaha
* Matches 0 or more
occurrence of a
token
a*h ah, aah, aaah, aaaah,
h, ha, haaha
Challenge 1:
Highlight the
first match for
string in
orange
Anchor Token
Token Property Regex Example Test String
^ Matches the
position at the start
of Line
^ah ah, aah, ha, aha,
ha<newline>ah
$ Matches the
position at the end
of Line
ah$ ah, aah, ha, aha,
ah<newline>ha
A Matches the
position at the start
of String
Aah ah, aah, ha, aha,
ha<newline>ah
Z Matches the
position at the end
of String
ahZ ah, aah, ha, aha,
ah<newline>ha
Character Token
Token Property Regex Example Test String
[a-zA-Z0-9] Matches one out of
several characters
gr[ea]y grey, gray, greay
[^a-zA-Z0-9] Matches any
character which is
not one of those in
the character set.
q[^u] qatar, Iraq,
[a-zA-Z0-9]+ Matches repeating
characters
[0-9]+ 333, 222, 123
[1st - [2nd]] Matches any one
character in first list
but not in the
second list.
[0-9-[02468]]+ 1357, 124, 111
Shortcut Character Token
Token Property Regex Example Test String
d Matches any digit d{1,9} 1, 123456789,
1234235259
s Matches any
whitespace
character
s+$ t, blank line with
spaces.
w Matches any word
character i.e.
letters, numbers, _
w{1,5} foo_1, $foo_1
D, S, W Matches opposite of
the above character
classes.
D+ Foobar, hello
world123!
Challenge 2:
Match 10 digit
mobile number
entered by user on
your signup form.
Ultimate Character - The .
The dot matches one of any character except the line break.
Challenge 2
^d{10,10}$
^$: Are anchor tags to
anchor to start and end of
input, prevents matching
abc0000000000
{10, 10}: matches
specifically 10 numbers
Solutions
Challenge 1
/a{1,3}h/ haaha
/a?h/ haaha
/a+h/ haaha
/a*h/ haaha
Let’s not get greedy.
We’ll dive deeper later!
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Hashing algorithms and its uses
Hashing algorithms and its usesHashing algorithms and its uses
Hashing algorithms and its usesJawad Khan
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1Dave Cross
 
Regular expression
Regular expressionRegular expression
Regular expressionLarry Nung
 
Modern Tools for API Testing, Debugging and Monitoring
Modern Tools for API Testing, Debugging and MonitoringModern Tools for API Testing, Debugging and Monitoring
Modern Tools for API Testing, Debugging and MonitoringNeil Mansilla
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expressionvaluebound
 
Slide #1:Introduction to Apache Storm
Slide #1:Introduction to Apache StormSlide #1:Introduction to Apache Storm
Slide #1:Introduction to Apache StormMd. Shamsur Rahim
 
알파희 - PyPy/RPython으로 20배 빨라지는 아희 JIT 인터프리터
알파희 - PyPy/RPython으로 20배 빨라지는 아희 JIT 인터프리터알파희 - PyPy/RPython으로 20배 빨라지는 아희 JIT 인터프리터
알파희 - PyPy/RPython으로 20배 빨라지는 아희 JIT 인터프리터YunWon Jeong
 
1. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES61. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES6pcnmtutorials
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular ExpressionsMatt Casto
 
chapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructionschapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructionswarda aziz
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Hitesh Patel
 
Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Bilal Amjad
 
Regex Presentation
Regex PresentationRegex Presentation
Regex Presentationarnolambert
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programmingKartik Sharma
 

Was ist angesagt? (20)

Hashing algorithms and its uses
Hashing algorithms and its usesHashing algorithms and its uses
Hashing algorithms and its uses
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
Html ppt
Html pptHtml ppt
Html ppt
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Php variables
Php variablesPhp variables
Php variables
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Modern Tools for API Testing, Debugging and Monitoring
Modern Tools for API Testing, Debugging and MonitoringModern Tools for API Testing, Debugging and Monitoring
Modern Tools for API Testing, Debugging and Monitoring
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Slide #1:Introduction to Apache Storm
Slide #1:Introduction to Apache StormSlide #1:Introduction to Apache Storm
Slide #1:Introduction to Apache Storm
 
Strings in C
Strings in CStrings in C
Strings in C
 
알파희 - PyPy/RPython으로 20배 빨라지는 아희 JIT 인터프리터
알파희 - PyPy/RPython으로 20배 빨라지는 아희 JIT 인터프리터알파희 - PyPy/RPython으로 20배 빨라지는 아희 JIT 인터프리터
알파희 - PyPy/RPython으로 20배 빨라지는 아희 JIT 인터프리터
 
1. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES61. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES6
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
 
chapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructionschapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructions
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12
 
Python programming
Python  programmingPython  programming
Python programming
 
Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)
 
Regex Presentation
Regex PresentationRegex Presentation
Regex Presentation
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
 

Ähnlich wie Introducing Regular Expressions

An Introduction to Regular expressions
An Introduction to Regular expressionsAn Introduction to Regular expressions
An Introduction to Regular expressionsYamagata Europe
 
Regular expressions in oracle
Regular expressions in oracleRegular expressions in oracle
Regular expressions in oracleLogan Palanisamy
 
Looking for Patterns
Looking for PatternsLooking for Patterns
Looking for PatternsKeith Wright
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsRaj Gupta
 
Regular Expressions 2007
Regular Expressions 2007Regular Expressions 2007
Regular Expressions 2007Geoffrey Dunn
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressionsmussawir20
 
Regular Expressions in PHP, MySQL by programmerblog.net
Regular Expressions in PHP, MySQL by programmerblog.netRegular Expressions in PHP, MySQL by programmerblog.net
Regular Expressions in PHP, MySQL by programmerblog.netProgrammer Blog
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressionsBen Brumfield
 
16 Java Regex
16 Java Regex16 Java Regex
16 Java Regexwayn
 
Regex startup
Regex startupRegex startup
Regex startupPayPal
 
Python (regular expression)
Python (regular expression)Python (regular expression)
Python (regular expression)Chirag Shetty
 
Basta mastering regex power
Basta mastering regex powerBasta mastering regex power
Basta mastering regex powerMax Kleiner
 
Regular Expression Cheat Sheet
Regular Expression Cheat SheetRegular Expression Cheat Sheet
Regular Expression Cheat SheetSydneyJohnson57
 

Ähnlich wie Introducing Regular Expressions (20)

Regex Basics
Regex BasicsRegex Basics
Regex Basics
 
2013 - Andrei Zmievski: Clínica Regex
2013 - Andrei Zmievski: Clínica Regex2013 - Andrei Zmievski: Clínica Regex
2013 - Andrei Zmievski: Clínica Regex
 
An Introduction to Regular expressions
An Introduction to Regular expressionsAn Introduction to Regular expressions
An Introduction to Regular expressions
 
Regex lecture
Regex lectureRegex lecture
Regex lecture
 
Regular expressions in oracle
Regular expressions in oracleRegular expressions in oracle
Regular expressions in oracle
 
Looking for Patterns
Looking for PatternsLooking for Patterns
Looking for Patterns
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular Expressions 2007
Regular Expressions 2007Regular Expressions 2007
Regular Expressions 2007
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressions
 
Regular Expressions in PHP, MySQL by programmerblog.net
Regular Expressions in PHP, MySQL by programmerblog.netRegular Expressions in PHP, MySQL by programmerblog.net
Regular Expressions in PHP, MySQL by programmerblog.net
 
Patterns
PatternsPatterns
Patterns
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
 
16 Java Regex
16 Java Regex16 Java Regex
16 Java Regex
 
Regex startup
Regex startupRegex startup
Regex startup
 
Python (regular expression)
Python (regular expression)Python (regular expression)
Python (regular expression)
 
Basta mastering regex power
Basta mastering regex powerBasta mastering regex power
Basta mastering regex power
 
Regex Intro
Regex IntroRegex Intro
Regex Intro
 
Regular Expression Cheat Sheet
Regular Expression Cheat SheetRegular Expression Cheat Sheet
Regular Expression Cheat Sheet
 
Ruby RegEx
Ruby RegExRuby RegEx
Ruby RegEx
 
RegEx Book.pdf
RegEx Book.pdfRegEx Book.pdf
RegEx Book.pdf
 

Mehr von Neha Jain

Bringing HTML5 uploads to SlideShare
Bringing HTML5 uploads to SlideShareBringing HTML5 uploads to SlideShare
Bringing HTML5 uploads to SlideShareNeha Jain
 
The power of happiness
The power of happinessThe power of happiness
The power of happinessNeha Jain
 
Houserentreceipt
HouserentreceiptHouserentreceipt
HouserentreceiptNeha Jain
 
Slideshareistestinginfographics regularupload
Slideshareistestinginfographics regularuploadSlideshareistestinginfographics regularupload
Slideshareistestinginfographics regularuploadNeha Jain
 
House rent receipt
House rent receiptHouse rent receipt
House rent receiptNeha Jain
 
Byte of vim_v051
Byte of vim_v051Byte of vim_v051
Byte of vim_v051Neha Jain
 

Mehr von Neha Jain (7)

FindIn
FindInFindIn
FindIn
 
Bringing HTML5 uploads to SlideShare
Bringing HTML5 uploads to SlideShareBringing HTML5 uploads to SlideShare
Bringing HTML5 uploads to SlideShare
 
The power of happiness
The power of happinessThe power of happiness
The power of happiness
 
Houserentreceipt
HouserentreceiptHouserentreceipt
Houserentreceipt
 
Slideshareistestinginfographics regularupload
Slideshareistestinginfographics regularuploadSlideshareistestinginfographics regularupload
Slideshareistestinginfographics regularupload
 
House rent receipt
House rent receiptHouse rent receipt
House rent receipt
 
Byte of vim_v051
Byte of vim_v051Byte of vim_v051
Byte of vim_v051
 

Kürzlich hochgeladen

Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 

Kürzlich hochgeladen (20)

9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 

Introducing Regular Expressions

  • 1. Regular Expressions Part 1: Basic Building Blocks
  • 2. What is a regular expression?
  • 3. Simple, an expression used regularly!
  • 4.
  • 5. /ah/ Yes that is a regular expression!
  • 6. You don’t believe me, try http://rubular.com/r/31xqIzPmPe /aah/
  • 7. Wonder how you’ll match /aaaaaaaa...h/
  • 8. Repetition Token Token Property Regex Example Test String {m, n} Match exact occurrences of a character/token a{1,3}h ah, aah, aaah, aaaah, h, ha, aha ? Matches 0 or 1 occurrence of a token a?h ah, aah, aaah, aaaah, h, ha, aha + Matches 1 or more occurrence of a token a+h ah, aah, aaah, aaaah, h, ha, aha * Matches 0 or more occurrence of a token a*h ah, aah, aaah, aaaah, h, ha, aha
  • 9. Repetition Token Token Property Regex Example Test String {m, n} Match exact occurrences of a character/token a{1,3}h ah, aah, aaah, aaaah, h, ha, haaha ? Matches 0 or 1 occurrence of a token a?h ah, aah, aaah, aaaah, h, ha, haaha + Matches 1 or more occurrence of a token a+h ah, aah, aaah, aaaah, h, ha, haaha * Matches 0 or more occurrence of a token a*h ah, aah, aaah, aaaah, h, ha, haaha Challenge 1: Highlight the first match for string in orange
  • 10. Anchor Token Token Property Regex Example Test String ^ Matches the position at the start of Line ^ah ah, aah, ha, aha, ha<newline>ah $ Matches the position at the end of Line ah$ ah, aah, ha, aha, ah<newline>ha A Matches the position at the start of String Aah ah, aah, ha, aha, ha<newline>ah Z Matches the position at the end of String ahZ ah, aah, ha, aha, ah<newline>ha
  • 11. Character Token Token Property Regex Example Test String [a-zA-Z0-9] Matches one out of several characters gr[ea]y grey, gray, greay [^a-zA-Z0-9] Matches any character which is not one of those in the character set. q[^u] qatar, Iraq, [a-zA-Z0-9]+ Matches repeating characters [0-9]+ 333, 222, 123 [1st - [2nd]] Matches any one character in first list but not in the second list. [0-9-[02468]]+ 1357, 124, 111
  • 12. Shortcut Character Token Token Property Regex Example Test String d Matches any digit d{1,9} 1, 123456789, 1234235259 s Matches any whitespace character s+$ t, blank line with spaces. w Matches any word character i.e. letters, numbers, _ w{1,5} foo_1, $foo_1 D, S, W Matches opposite of the above character classes. D+ Foobar, hello world123!
  • 13. Challenge 2: Match 10 digit mobile number entered by user on your signup form.
  • 14. Ultimate Character - The . The dot matches one of any character except the line break.
  • 15. Challenge 2 ^d{10,10}$ ^$: Are anchor tags to anchor to start and end of input, prevents matching abc0000000000 {10, 10}: matches specifically 10 numbers Solutions Challenge 1 /a{1,3}h/ haaha /a?h/ haaha /a+h/ haaha /a*h/ haaha
  • 16. Let’s not get greedy. We’ll dive deeper later!