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?

JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The BasicsJeff Fox
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluationJeeSa Sultana
 
Redis cluster
Redis clusterRedis cluster
Redis clusteriammutex
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressionsBen Brumfield
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Clean Code summary
Clean Code summaryClean Code summary
Clean Code summaryJan de Vries
 
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenMichael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenPostgresOpen
 
C++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkHumberto Marchezi
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionsaber tabatabaee
 
Regular expression
Regular expressionRegular expression
Regular expressionLarry Nung
 
Multi level inheritence
Multi level inheritenceMulti level inheritence
Multi level inheritenceRanaMOIN1
 
The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean codeVictor Rentea
 

Was ist angesagt? (20)

JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Clean Code summary
Clean Code summaryClean Code summary
Clean Code summary
 
Clean Code
Clean CodeClean Code
Clean Code
 
The Stack And Recursion
The Stack And RecursionThe Stack And Recursion
The Stack And Recursion
 
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenMichael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
 
Python Programming Essentials - M8 - String Methods
Python Programming Essentials - M8 - String MethodsPython Programming Essentials - M8 - String Methods
Python Programming Essentials - M8 - String Methods
 
jQuery
jQueryjQuery
jQuery
 
Clean code
Clean codeClean code
Clean code
 
C++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing Framework
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Json
JsonJson
Json
 
GMock framework
GMock frameworkGMock framework
GMock framework
 
Multi level inheritence
Multi level inheritenceMulti level inheritence
Multi level inheritence
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean code
 

Ä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
 
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
 
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
 
Lecture 10.pdf
Lecture 10.pdfLecture 10.pdf
Lecture 10.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

High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSsandhya757531
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfShreyas Pandit
 
Comprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdfComprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdfalene1
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical trainingGladiatorsKasper
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESkarthi keyan
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsResearcher Researcher
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labsamber724300
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Romil Mishra
 
Forming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).pptForming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).pptNoman khan
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodManicka Mamallan Andavar
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 

Kürzlich hochgeladen (20)

High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdf
 
Comprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdfComprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdf
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending Actuators
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labs
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________
 
Forming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).pptForming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).ppt
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument method
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 

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!