SlideShare a Scribd company logo
1 of 16
Download to read offline
Regular Expressions
… and Their Place in the QA Engineer's Life
Svetlin Nakov
Manager Training
and Inspiration
Software University
http://softuni.bg
What are Regular Expressions?
• Regular expressions (regex)
– Match text by pattern
• Patterns are defined by special syntax, e.g.
– [0-9]+ matches non-empty sequence of digits
– [A-Z][a-z]* matches a capital + small letters
– s+ matches whitespace (non-empty)
• S+ matches non-whitespace
2
3
DEMO
www.regexr.com
More Patterns
• d+ matches digits
– D+ matches non-digits
• w+ matches letters (Unicode)
– W+ matches non-letters
• +d{1,3}([ -]*[0-9]){6,} matches
international phone, e.g. +359 2 123-456
4
5
DEMO
www.regexr.com
Validation by Regex
• ^ matches start of text
• $ matches end of text
• ^+d{1,3}([ -]*[0-9]){6,}$ validates
international phone
• +359 2 123-456 is a valid phone
• +359 (888) 123-456 is a invalid phone
6
7
DEMO
www.regexr.com
Regex Literals
• The classical (Perl syntax) is:
– /<regex>/<options>
• Examples:
– /[a-z]+/gi matches all non-empty sequences
of Latin letters, case-insensitively
– /[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,20}/gi
matches emails (simplified pattern)
8
9
DEMO
www.debuggex.com
Some JS Code: Validation
var emailPattern =
/^[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,20}$/i;
console.log(emailPattern.test("test@abv.bg"));
console.log(emailPattern.test("a.hills@gtx.de"));
console.log(emailPattern.test("invalid@@mail"));
console.log(emailPattern.test("err test@abv.bg"));
10
Some JS Code: Split
var towns = "Sofia, Varna,Pleven, Veliko Tarnovo;
Paris – London––Vienann Пловдив|Каспичан";
console.log(towns.split(/W+/)); // incorrect
console.log(towns.split(/s*[.,|;nt–]+s*/));
11
Some JS Code: Match
var text = "I was born at 14-Jun-1980. Today is
14-Mar-2015. Next year starts at 1-Jan-2016 and
ends at 31-Dec-2016.";
var dateRegex = /d{1,2}-w{3}-d{4}/gm;
console.log(text.match(dateRegex));
12
Regex for QA Engineers
• Why should a QA understand regex?
– Validation  prepare regex for developers
– Write automation testing scripts
• E.g. find a text on the page by regex
– Parse a text, extract info, split data, …
13
Resources
• Play with regex:
– http://www.regexr.com
– https://regex101.com
• Visual regex debugger:
– https://www.debuggex.com
• Regex explained (in Bulgarian)
– http://goo.gl/NbBIPe
–
14
Resources (2)
• Interactive Regex Tutorial
– http://regexone.com
• Regex @ W3Schools
– http://w3schools.com/jsref/jsref_obj_regexp.asp
• Regex Tutorial (for Java)
– vogella.com/tutorials/JavaRegularExpressions/article.html
15
Regular Expressions
Questions?
16

More Related Content

Viewers also liked

Slide typescript - xe dotnet - Codemotion Rome 2015
Slide typescript - xe dotnet - Codemotion Rome 2015Slide typescript - xe dotnet - Codemotion Rome 2015
Slide typescript - xe dotnet - Codemotion Rome 2015
Codemotion
 
Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")
Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")
Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")
Svetlin Nakov
 
Работа с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клуб
Работа с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клубРабота с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клуб
Работа с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клуб
Svetlin Nakov
 
Architetttura Della Soluzione
Architetttura Della SoluzioneArchitetttura Della Soluzione
Architetttura Della Soluzione
Luca Milan
 

Viewers also liked (20)

Slavy Slavov - 6 Common Challenges Setting Up Selenium in High Scale
Slavy Slavov - 6 Common Challenges Setting Up Selenium in High ScaleSlavy Slavov - 6 Common Challenges Setting Up Selenium in High Scale
Slavy Slavov - 6 Common Challenges Setting Up Selenium in High Scale
 
Veselin Berov - Testing in the World of Information Management
Veselin Berov - Testing in the World of Information ManagementVeselin Berov - Testing in the World of Information Management
Veselin Berov - Testing in the World of Information Management
 
Професия QA инженер - SoftUniConf June 2015
Професия QA инженер - SoftUniConf June 2015Професия QA инженер - SoftUniConf June 2015
Професия QA инженер - SoftUniConf June 2015
 
System.AddIn @ Xe.Net
System.AddIn @ Xe.NetSystem.AddIn @ Xe.Net
System.AddIn @ Xe.Net
 
SUE AGILE MVVM (Italian)
SUE AGILE MVVM (Italian)SUE AGILE MVVM (Italian)
SUE AGILE MVVM (Italian)
 
Nakov at Fuck Up Nights - July 2015 @ Sofia
Nakov at Fuck Up Nights - July 2015 @ SofiaNakov at Fuck Up Nights - July 2015 @ Sofia
Nakov at Fuck Up Nights - July 2015 @ Sofia
 
Slide typescript - xe dotnet - Codemotion Rome 2015
Slide typescript - xe dotnet - Codemotion Rome 2015Slide typescript - xe dotnet - Codemotion Rome 2015
Slide typescript - xe dotnet - Codemotion Rome 2015
 
Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")
Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")
Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")
 
Introduzione a MVVM e Caliburn.Micro
Introduzione a MVVM e Caliburn.MicroIntroduzione a MVVM e Caliburn.Micro
Introduzione a MVVM e Caliburn.Micro
 
Slide Prelaurea. Alessandro Andreosè
Slide Prelaurea. Alessandro AndreosèSlide Prelaurea. Alessandro Andreosè
Slide Prelaurea. Alessandro Andreosè
 
Професия "програмист"
Професия "програмист"Професия "програмист"
Професия "програмист"
 
Dependency Injection and Inversion Of Control
Dependency Injection and Inversion Of ControlDependency Injection and Inversion Of Control
Dependency Injection and Inversion Of Control
 
Inversion of Control @ CD2008
Inversion of Control @ CD2008Inversion of Control @ CD2008
Inversion of Control @ CD2008
 
Как да станем софтуерни инженери и да стартираме ИТ бизнес?
Как да станем софтуерни инженери и да стартираме ИТ бизнес?Как да станем софтуерни инженери и да стартираме ИТ бизнес?
Как да станем софтуерни инженери и да стартираме ИТ бизнес?
 
Model-View-ViewModel
Model-View-ViewModelModel-View-ViewModel
Model-View-ViewModel
 
Работа с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клуб
Работа с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клубРабота с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клуб
Работа с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клуб
 
Architetttura Della Soluzione
Architetttura Della SoluzioneArchitetttura Della Soluzione
Architetttura Della Soluzione
 
UI Composition
UI CompositionUI Composition
UI Composition
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Introduzione WPF
Introduzione WPFIntroduzione WPF
Introduzione WPF
 

Similar to Regular Expressions: QA Challenge Accepted Conf (March 2015)

Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and You
James Armes
 
OISF: Regular Expressions (Regex) Overview
OISF: Regular Expressions (Regex) OverviewOISF: Regular Expressions (Regex) Overview
OISF: Regular Expressions (Regex) Overview
ThreatReel Podcast
 
Regular Expressions Boot Camp
Regular Expressions Boot CampRegular Expressions Boot Camp
Regular Expressions Boot Camp
Chris Schiffhauer
 

Similar to Regular Expressions: QA Challenge Accepted Conf (March 2015) (20)

Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Week-2: Theory & Practice of Data Cleaning: Regular Expressions in Practice
Week-2: Theory & Practice of Data Cleaning: Regular Expressions in PracticeWeek-2: Theory & Practice of Data Cleaning: Regular Expressions in Practice
Week-2: Theory & Practice of Data Cleaning: Regular Expressions in Practice
 
Regular expression for everyone
Regular expression for everyoneRegular expression for everyone
Regular expression for everyone
 
Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and You
 
regex_presentation.pptx
regex_presentation.pptxregex_presentation.pptx
regex_presentation.pptx
 
MarcEdit Shelter-In-Place Webinar 6: Regular Expressions and .NET, A Primer
MarcEdit Shelter-In-Place Webinar 6: Regular Expressions and .NET, A PrimerMarcEdit Shelter-In-Place Webinar 6: Regular Expressions and .NET, A Primer
MarcEdit Shelter-In-Place Webinar 6: Regular Expressions and .NET, A Primer
 
OISF: Regular Expressions (Regex) Overview
OISF: Regular Expressions (Regex) OverviewOISF: Regular Expressions (Regex) Overview
OISF: Regular Expressions (Regex) Overview
 
Regular Expressions 2007
Regular Expressions 2007Regular Expressions 2007
Regular Expressions 2007
 
DerbyCon 7.0 Legacy: Regular Expressions (Regex) Overview
DerbyCon 7.0 Legacy: Regular Expressions (Regex) OverviewDerbyCon 7.0 Legacy: Regular Expressions (Regex) Overview
DerbyCon 7.0 Legacy: Regular Expressions (Regex) Overview
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular Expression in Action
Regular Expression in ActionRegular Expression in Action
Regular Expression in Action
 
Regular Expressions Boot Camp
Regular Expressions Boot CampRegular Expressions Boot Camp
Regular Expressions Boot Camp
 
How to check valid Email? Find using regex.
How to check valid Email? Find using regex.How to check valid Email? Find using regex.
How to check valid Email? Find using regex.
 
Modules 17 12_2020
Modules 17 12_2020Modules 17 12_2020
Modules 17 12_2020
 
Lecture 10.pdf
Lecture 10.pdfLecture 10.pdf
Lecture 10.pdf
 
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
 
22 spam
22 spam22 spam
22 spam
 
Regex intro
Regex introRegex intro
Regex intro
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 

More from Svetlin Nakov

Дипломна работа: учебно съдържание по ООП - Светлин Наков
Дипломна работа: учебно съдържание по ООП - Светлин НаковДипломна работа: учебно съдържание по ООП - Светлин Наков
Дипломна работа: учебно съдържание по ООП - Светлин Наков
Svetlin Nakov
 
Свободно ИТ учебно съдържание за учители по програмиране и ИТ
Свободно ИТ учебно съдържание за учители по програмиране и ИТСвободно ИТ учебно съдържание за учители по програмиране и ИТ
Свободно ИТ учебно съдържание за учители по програмиране и ИТ
Svetlin Nakov
 
Blockchain and DeFi Overview (Nakov, Sept 2021)
Blockchain and DeFi Overview (Nakov, Sept 2021)Blockchain and DeFi Overview (Nakov, Sept 2021)
Blockchain and DeFi Overview (Nakov, Sept 2021)
Svetlin Nakov
 

More from Svetlin Nakov (20)

BG-IT-Edu: отворено учебно съдържание за ИТ учители
BG-IT-Edu: отворено учебно съдържание за ИТ учителиBG-IT-Edu: отворено учебно съдържание за ИТ учители
BG-IT-Edu: отворено учебно съдържание за ИТ учители
 
Programming World in 2024
Programming World in 2024Programming World in 2024
Programming World in 2024
 
AI Tools for Business and Startups
AI Tools for Business and StartupsAI Tools for Business and Startups
AI Tools for Business and Startups
 
AI Tools for Scientists - Nakov (Oct 2023)
AI Tools for Scientists - Nakov (Oct 2023)AI Tools for Scientists - Nakov (Oct 2023)
AI Tools for Scientists - Nakov (Oct 2023)
 
AI Tools for Entrepreneurs
AI Tools for EntrepreneursAI Tools for Entrepreneurs
AI Tools for Entrepreneurs
 
Bulgarian Tech Industry - Nakov at Dev.BG All in One Conference 2023
Bulgarian Tech Industry - Nakov at Dev.BG All in One Conference 2023Bulgarian Tech Industry - Nakov at Dev.BG All in One Conference 2023
Bulgarian Tech Industry - Nakov at Dev.BG All in One Conference 2023
 
AI Tools for Business and Personal Life
AI Tools for Business and Personal LifeAI Tools for Business and Personal Life
AI Tools for Business and Personal Life
 
Дипломна работа: учебно съдържание по ООП - Светлин Наков
Дипломна работа: учебно съдържание по ООП - Светлин НаковДипломна работа: учебно съдържание по ООП - Светлин Наков
Дипломна работа: учебно съдържание по ООП - Светлин Наков
 
Дипломна работа: учебно съдържание по ООП
Дипломна работа: учебно съдържание по ООПДипломна работа: учебно съдържание по ООП
Дипломна работа: учебно съдържание по ООП
 
Свободно ИТ учебно съдържание за учители по програмиране и ИТ
Свободно ИТ учебно съдържание за учители по програмиране и ИТСвободно ИТ учебно съдържание за учители по програмиране и ИТ
Свободно ИТ учебно съдържание за учители по програмиране и ИТ
 
AI and the Professions of the Future
AI and the Professions of the FutureAI and the Professions of the Future
AI and the Professions of the Future
 
Programming Languages Trends for 2023
Programming Languages Trends for 2023Programming Languages Trends for 2023
Programming Languages Trends for 2023
 
IT Professions and How to Become a Developer
IT Professions and How to Become a DeveloperIT Professions and How to Become a Developer
IT Professions and How to Become a Developer
 
GitHub Actions (Nakov at RuseConf, Sept 2022)
GitHub Actions (Nakov at RuseConf, Sept 2022)GitHub Actions (Nakov at RuseConf, Sept 2022)
GitHub Actions (Nakov at RuseConf, Sept 2022)
 
IT Professions and Their Future
IT Professions and Their FutureIT Professions and Their Future
IT Professions and Their Future
 
How to Become a QA Engineer and Start a Job
How to Become a QA Engineer and Start a JobHow to Become a QA Engineer and Start a Job
How to Become a QA Engineer and Start a Job
 
Призвание и цели: моята рецепта
Призвание и цели: моята рецептаПризвание и цели: моята рецепта
Призвание и цели: моята рецепта
 
What Mongolian IT Industry Can Learn from Bulgaria?
What Mongolian IT Industry Can Learn from Bulgaria?What Mongolian IT Industry Can Learn from Bulgaria?
What Mongolian IT Industry Can Learn from Bulgaria?
 
How to Become a Software Developer - Nakov in Mongolia (Oct 2022)
How to Become a Software Developer - Nakov in Mongolia (Oct 2022)How to Become a Software Developer - Nakov in Mongolia (Oct 2022)
How to Become a Software Developer - Nakov in Mongolia (Oct 2022)
 
Blockchain and DeFi Overview (Nakov, Sept 2021)
Blockchain and DeFi Overview (Nakov, Sept 2021)Blockchain and DeFi Overview (Nakov, Sept 2021)
Blockchain and DeFi Overview (Nakov, Sept 2021)
 

Recently uploaded

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 

Regular Expressions: QA Challenge Accepted Conf (March 2015)

  • 1. Regular Expressions … and Their Place in the QA Engineer's Life Svetlin Nakov Manager Training and Inspiration Software University http://softuni.bg
  • 2. What are Regular Expressions? • Regular expressions (regex) – Match text by pattern • Patterns are defined by special syntax, e.g. – [0-9]+ matches non-empty sequence of digits – [A-Z][a-z]* matches a capital + small letters – s+ matches whitespace (non-empty) • S+ matches non-whitespace 2
  • 4. More Patterns • d+ matches digits – D+ matches non-digits • w+ matches letters (Unicode) – W+ matches non-letters • +d{1,3}([ -]*[0-9]){6,} matches international phone, e.g. +359 2 123-456 4
  • 6. Validation by Regex • ^ matches start of text • $ matches end of text • ^+d{1,3}([ -]*[0-9]){6,}$ validates international phone • +359 2 123-456 is a valid phone • +359 (888) 123-456 is a invalid phone 6
  • 8. Regex Literals • The classical (Perl syntax) is: – /<regex>/<options> • Examples: – /[a-z]+/gi matches all non-empty sequences of Latin letters, case-insensitively – /[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,20}/gi matches emails (simplified pattern) 8
  • 10. Some JS Code: Validation var emailPattern = /^[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,20}$/i; console.log(emailPattern.test("test@abv.bg")); console.log(emailPattern.test("a.hills@gtx.de")); console.log(emailPattern.test("invalid@@mail")); console.log(emailPattern.test("err test@abv.bg")); 10
  • 11. Some JS Code: Split var towns = "Sofia, Varna,Pleven, Veliko Tarnovo; Paris – London––Vienann Пловдив|Каспичан"; console.log(towns.split(/W+/)); // incorrect console.log(towns.split(/s*[.,|;nt–]+s*/)); 11
  • 12. Some JS Code: Match var text = "I was born at 14-Jun-1980. Today is 14-Mar-2015. Next year starts at 1-Jan-2016 and ends at 31-Dec-2016."; var dateRegex = /d{1,2}-w{3}-d{4}/gm; console.log(text.match(dateRegex)); 12
  • 13. Regex for QA Engineers • Why should a QA understand regex? – Validation  prepare regex for developers – Write automation testing scripts • E.g. find a text on the page by regex – Parse a text, extract info, split data, … 13
  • 14. Resources • Play with regex: – http://www.regexr.com – https://regex101.com • Visual regex debugger: – https://www.debuggex.com • Regex explained (in Bulgarian) – http://goo.gl/NbBIPe – 14
  • 15. Resources (2) • Interactive Regex Tutorial – http://regexone.com • Regex @ W3Schools – http://w3schools.com/jsref/jsref_obj_regexp.asp • Regex Tutorial (for Java) – vogella.com/tutorials/JavaRegularExpressions/article.html 15