SlideShare a Scribd company logo
REGULAR EXPRESSIONSREGULAR EXPRESSIONS
WHAT IS REGULAR EXPRESSION?WHAT IS REGULAR EXPRESSION?
A regular expression, regex or regexp (sometimes
called a rational expression) is a sequence of characters
that de ne a search pattern.
Wikipedia
MDN
JS book
WHERE DO WE USE REGULAR EXPRESSIONS?WHERE DO WE USE REGULAR EXPRESSIONS?
Search engines
Data validation
Data scraping (especially web scraping)
Data wrangling
Parsing
PATTERNS AND FLAGSPATTERNS AND FLAGS
PATTERNSPATTERNS
The “long” syntax:
The “short” one, using slashes "/":
Inserting variables in string:
let regexp = new RegExp("pattern", "flags");1
let regexp = /pattern/; // no flags
let regexp = /pattern/g; // with flags g
1
2
let language = 'JavaScript';
let regexp = new RegExp(`${language} is the awesome!`);
1
2
FLAGSFLAGS
i (case-insensitive search)
g (the search looks for all matches)
y (“Sticky” mode)
u (full unicode support)
m (multiline mode)
s (“dotall” mode)
SEARCHING: STR.MATCH()SEARCHING: STR.MATCH()
1. If the regular expression has ag g, it returns an array
of all matches:
2. Otherwise returns only the rst match in the form of
an array with additional information:
3. If there are no matches, null is returned:
let res = 'We will we will'.match(/we/gi); // We we1
let res = 'We will we will'.match(/we/); // we groups index1
let res = 'JavaScript'.match(/HTML/); // null1
METACHARACTERSMETACHARACTERS
SETS AND RANGES [...]SETS AND RANGES [...]
A bracket expression. Matches a single character that is
contained within the brackets.
Square brackets may also contain character ranges.
Besides normal ranges, there are “excluding” ranges
that look like [^…]. const matches = 'Mop top
wop'.match(/[^tm]op/gi) // wop
let matches = 'Mop top'.match(/[tm]op/gi) // Mop top1
let matches = 'Zebra Zebrb Zebrz'.match(/Zebr[a-z]/gi) // Zebra1
CHARACTER CLASSESCHARACTER CLASSES
d (“d” is from “digit”) - same as [0-9]
s (“s” is from “space”) - same as [ trnvf]
w (“w” is from “word”) - same as [A-Za-z0-9_]
D - non-digits - same as [^0-9]
S – all but s - same as [^ trnvf]
W – all but w - same as [^A-Za-z0-9_]
"." - any character except a newline (any character
with 's' ag)
QUANTIFIERS +, *, ? AND {N}QUANTIFIERS +, *, ? AND {N}
The exact count: {n}
The range: {n, m}, match n-m times:
The range without upper limit: {n,}
let answer = "I'm 12345 years old".match(/d{5}/); // "12345"1
let answer = "I'm 1234 years old".match(/d{3,5}/); // "1234"1
let answer = "I'm 345678 years old".match(/d{3,}/); // "3456781
QUANTIFIERS +, *, ? AND {N}QUANTIFIERS +, *, ? AND {N}
+ “one or more” - same as {1,}
? “zero or one” - same as {0,1}
* “zero or more” - same as {0,}
let str = '100 10 1'.match(/d0+/g) ); // 100 101
let res = 'Colour or color?'.match(/colou?r/g); // color colour1
let str = '100 10 1'.match(/d0*/g); // 100, 10, 11
ANCHORS: STRING START ^ AND END $ANCHORS: STRING START ^ AND END $
Examples:
Multiline example:
let regexp = /^Hello.*/; // starts with Hello
let pattern = /.*Bye$/; // ends with Bye'
1
2
let str = `1st place: Winnie
2nd place: Piglet
3rd place: Eeyore`;
let result = str.match(/^d/gm); // 1, 2, 3
1
2
3
4
5
CAPTURING GROUPSCAPTURING GROUPS
Parentheses group characters together:
Parentheses group characters together:
'Gogogo now!'.match(/(go)+/i); // Gogogo1
let str = '<span class="my">';
let regexp = /<(([a-z]+)s*([^>]*))>/;
let result = str.match(regexp);
alert(result[0]); // <span class="my">
alert(result[1]); // span class="my"
alert(result[2]); // span
alert(result[3]); // class="my"</span></span>
1
2
3
4
5
6
7
8
ALTERNATION (OR) |ALTERNATION (OR) |
A usage example:
let res = 'Gray or grey?'.match(/gr(a|e)y/g); // Gray grey1
CONCLUSIONCONCLUSION
Problems:
Can't be used for recursive structures
Can be very slow solving complex logic
THANK YOU FORTHANK YOU FOR
ATTENTION!ATTENTION!

More Related Content

Similar to Regular expressions

Coffee 'n code: Regexes
Coffee 'n code: RegexesCoffee 'n code: Regexes
Coffee 'n code: Regexes
Phil Ewels
 
Ruby RegEx
Ruby RegExRuby RegEx
Ruby RegEx
Sarah Allen
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
Ahmed Swilam
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ignaz Wanders
 
Lecture 23
Lecture 23Lecture 23
Lecture 23rhshriva
 
Eag 201110-hrugregexpresentation-111006104128-phpapp02
Eag 201110-hrugregexpresentation-111006104128-phpapp02Eag 201110-hrugregexpresentation-111006104128-phpapp02
Eag 201110-hrugregexpresentation-111006104128-phpapp02
egoodwintx
 
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
Prof. Wim Van Criekinge
 
Eloquent Ruby chapter 4 - Find The Right String with Regular Expression
Eloquent Ruby chapter 4 - Find The Right String with Regular ExpressionEloquent Ruby chapter 4 - Find The Right String with Regular Expression
Eloquent Ruby chapter 4 - Find The Right String with Regular ExpressionKuyseng Chhoeun
 
Form validation client side
Form validation client side Form validation client side
Form validation client side
Mudasir Syed
 
Json
JsonJson
Basta mastering regex power
Basta mastering regex powerBasta mastering regex power
Basta mastering regex power
Max Kleiner
 
Regular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And BeyondRegular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And Beyond
Max Shirshin
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
keeyre
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
WebStackAcademy
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
Lambert Lum
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regex
Jalpesh Vasa
 

Similar to Regular expressions (20)

Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Coffee 'n code: Regexes
Coffee 'n code: RegexesCoffee 'n code: Regexes
Coffee 'n code: Regexes
 
Ruby RegEx
Ruby RegExRuby RegEx
Ruby RegEx
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Eag 201110-hrugregexpresentation-111006104128-phpapp02
Eag 201110-hrugregexpresentation-111006104128-phpapp02Eag 201110-hrugregexpresentation-111006104128-phpapp02
Eag 201110-hrugregexpresentation-111006104128-phpapp02
 
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
 
Bioinformatica p2-p3-introduction
Bioinformatica p2-p3-introductionBioinformatica p2-p3-introduction
Bioinformatica p2-p3-introduction
 
Eloquent Ruby chapter 4 - Find The Right String with Regular Expression
Eloquent Ruby chapter 4 - Find The Right String with Regular ExpressionEloquent Ruby chapter 4 - Find The Right String with Regular Expression
Eloquent Ruby chapter 4 - Find The Right String with Regular Expression
 
Form validation client side
Form validation client side Form validation client side
Form validation client side
 
Json
JsonJson
Json
 
Javascript2839
Javascript2839Javascript2839
Javascript2839
 
Basta mastering regex power
Basta mastering regex powerBasta mastering regex power
Basta mastering regex power
 
Regular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And BeyondRegular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And Beyond
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regex
 

Recently uploaded

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
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
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
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
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
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
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 

Recently uploaded (20)

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
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
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
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
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
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
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 

Regular expressions

  • 2. WHAT IS REGULAR EXPRESSION?WHAT IS REGULAR EXPRESSION? A regular expression, regex or regexp (sometimes called a rational expression) is a sequence of characters that de ne a search pattern. Wikipedia MDN JS book
  • 3. WHERE DO WE USE REGULAR EXPRESSIONS?WHERE DO WE USE REGULAR EXPRESSIONS? Search engines Data validation Data scraping (especially web scraping) Data wrangling Parsing
  • 5. PATTERNSPATTERNS The “long” syntax: The “short” one, using slashes "/": Inserting variables in string: let regexp = new RegExp("pattern", "flags");1 let regexp = /pattern/; // no flags let regexp = /pattern/g; // with flags g 1 2 let language = 'JavaScript'; let regexp = new RegExp(`${language} is the awesome!`); 1 2
  • 6. FLAGSFLAGS i (case-insensitive search) g (the search looks for all matches) y (“Sticky” mode) u (full unicode support) m (multiline mode) s (“dotall” mode)
  • 7. SEARCHING: STR.MATCH()SEARCHING: STR.MATCH() 1. If the regular expression has ag g, it returns an array of all matches: 2. Otherwise returns only the rst match in the form of an array with additional information: 3. If there are no matches, null is returned: let res = 'We will we will'.match(/we/gi); // We we1 let res = 'We will we will'.match(/we/); // we groups index1 let res = 'JavaScript'.match(/HTML/); // null1
  • 9. SETS AND RANGES [...]SETS AND RANGES [...] A bracket expression. Matches a single character that is contained within the brackets. Square brackets may also contain character ranges. Besides normal ranges, there are “excluding” ranges that look like [^…]. const matches = 'Mop top wop'.match(/[^tm]op/gi) // wop let matches = 'Mop top'.match(/[tm]op/gi) // Mop top1 let matches = 'Zebra Zebrb Zebrz'.match(/Zebr[a-z]/gi) // Zebra1
  • 10. CHARACTER CLASSESCHARACTER CLASSES d (“d” is from “digit”) - same as [0-9] s (“s” is from “space”) - same as [ trnvf] w (“w” is from “word”) - same as [A-Za-z0-9_] D - non-digits - same as [^0-9] S – all but s - same as [^ trnvf] W – all but w - same as [^A-Za-z0-9_] "." - any character except a newline (any character with 's' ag)
  • 11. QUANTIFIERS +, *, ? AND {N}QUANTIFIERS +, *, ? AND {N} The exact count: {n} The range: {n, m}, match n-m times: The range without upper limit: {n,} let answer = "I'm 12345 years old".match(/d{5}/); // "12345"1 let answer = "I'm 1234 years old".match(/d{3,5}/); // "1234"1 let answer = "I'm 345678 years old".match(/d{3,}/); // "3456781
  • 12. QUANTIFIERS +, *, ? AND {N}QUANTIFIERS +, *, ? AND {N} + “one or more” - same as {1,} ? “zero or one” - same as {0,1} * “zero or more” - same as {0,} let str = '100 10 1'.match(/d0+/g) ); // 100 101 let res = 'Colour or color?'.match(/colou?r/g); // color colour1 let str = '100 10 1'.match(/d0*/g); // 100, 10, 11
  • 13. ANCHORS: STRING START ^ AND END $ANCHORS: STRING START ^ AND END $ Examples: Multiline example: let regexp = /^Hello.*/; // starts with Hello let pattern = /.*Bye$/; // ends with Bye' 1 2 let str = `1st place: Winnie 2nd place: Piglet 3rd place: Eeyore`; let result = str.match(/^d/gm); // 1, 2, 3 1 2 3 4 5
  • 14. CAPTURING GROUPSCAPTURING GROUPS Parentheses group characters together: Parentheses group characters together: 'Gogogo now!'.match(/(go)+/i); // Gogogo1 let str = '<span class="my">'; let regexp = /<(([a-z]+)s*([^>]*))>/; let result = str.match(regexp); alert(result[0]); // <span class="my"> alert(result[1]); // span class="my" alert(result[2]); // span alert(result[3]); // class="my"</span></span> 1 2 3 4 5 6 7 8
  • 15. ALTERNATION (OR) |ALTERNATION (OR) | A usage example: let res = 'Gray or grey?'.match(/gr(a|e)y/g); // Gray grey1
  • 16. CONCLUSIONCONCLUSION Problems: Can't be used for recursive structures Can be very slow solving complex logic
  • 17. THANK YOU FORTHANK YOU FOR ATTENTION!ATTENTION!