SlideShare a Scribd company logo
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 (20)

PPTX
Slavy Slavov - 6 Common Challenges Setting Up Selenium in High Scale
Peter Sabev
 
PPT
Veselin Berov - Testing in the World of Information Management
Peter Sabev
 
PPTX
Професия QA инженер - SoftUniConf June 2015
Peter Sabev
 
PPTX
System.AddIn @ Xe.Net
Mauro Servienti
 
PDF
SUE AGILE MVVM (Italian)
Sabino Labarile
 
PPTX
Nakov at Fuck Up Nights - July 2015 @ Sofia
Svetlin Nakov
 
PPTX
Slide typescript - xe dotnet - Codemotion Rome 2015
Codemotion
 
PPTX
Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")
Svetlin Nakov
 
PPTX
Introduzione a MVVM e Caliburn.Micro
Massimo Bonanni
 
PDF
Slide Prelaurea. Alessandro Andreosè
guesta10af3
 
PPTX
Професия "програмист"
Svetlin Nakov
 
PPTX
Dependency Injection and Inversion Of Control
Simone Busoli
 
PPTX
Inversion of Control @ CD2008
Mauro Servienti
 
PDF
Как да станем софтуерни инженери и да стартираме ИТ бизнес?
Svetlin Nakov
 
PPTX
Model-View-ViewModel
DotNetMarche
 
PPTX
Работа с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клуб
Svetlin Nakov
 
PDF
Architetttura Della Soluzione
Luca Milan
 
PPTX
UI Composition
DotNetMarche
 
PPTX
Dependency Injection
Raffaele Fanizzi
 
PPT
Introduzione WPF
Ercole Palmeri
 
Slavy Slavov - 6 Common Challenges Setting Up Selenium in High Scale
Peter Sabev
 
Veselin Berov - Testing in the World of Information Management
Peter Sabev
 
Професия QA инженер - SoftUniConf June 2015
Peter Sabev
 
System.AddIn @ Xe.Net
Mauro Servienti
 
SUE AGILE MVVM (Italian)
Sabino Labarile
 
Nakov at Fuck Up Nights - July 2015 @ Sofia
Svetlin Nakov
 
Slide typescript - xe dotnet - Codemotion Rome 2015
Codemotion
 
Следвай вдъхновението си! (фестивал "Свободата да бъдеш - април 2016")
Svetlin Nakov
 
Introduzione a MVVM e Caliburn.Micro
Massimo Bonanni
 
Slide Prelaurea. Alessandro Andreosè
guesta10af3
 
Професия "програмист"
Svetlin Nakov
 
Dependency Injection and Inversion Of Control
Simone Busoli
 
Inversion of Control @ CD2008
Mauro Servienti
 
Как да станем софтуерни инженери и да стартираме ИТ бизнес?
Svetlin Nakov
 
Model-View-ViewModel
DotNetMarche
 
Работа с Естествен Интелект – Личност – Време – 3 юли 2013 @ НЛП клуб
Svetlin Nakov
 
Architetttura Della Soluzione
Luca Milan
 
UI Composition
DotNetMarche
 
Dependency Injection
Raffaele Fanizzi
 
Introduzione WPF
Ercole Palmeri
 

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

PPT
Regular Expression in Action
Folio3 Software
 
PDF
Regexp
Ynon Perek
 
PPTX
Regular Expressions(Theory of programming languages))
khudabux1998
 
PPTX
Regular Expression Crash Course
Imran Qasim
 
PDF
Regular expression presentation for the HUB
thehoagie
 
ODP
CiNPA Security SIG - Regex Presentation
ThreatReel Podcast
 
ODP
Regular Expressions and You
James Armes
 
PPTX
Regular expressions
Eran Zimbler
 
PDF
Week-2: Theory & Practice of Data Cleaning: Regular Expressions in Theory
Bertram Ludäscher
 
PPTX
Regular Expressions
Akhil Kaushik
 
PDF
Regular Expressions 101
Kai Koenig
 
PPTX
Regular expressions
Ignaz Wanders
 
PPTX
Regular Expression
Syed Owais Ali Chishti
 
PPT
regex.ppt
ansariparveen06
 
KEY
Regular Expressions 101
Raj Rajandran
 
PPT
Regular Expressions 2007
Geoffrey Dunn
 
PDF
/Regex makes me want to (weep_give up_(╯°□°)╯︵ ┻━┻)/i (for 2024 CascadiaPHP)
brettflorio
 
ODP
OISF: Regular Expressions (Regex) Overview
ThreatReel Podcast
 
ODP
Regex Presentation
arnolambert
 
ODP
Regex Presentation
arnolambert
 
Regular Expression in Action
Folio3 Software
 
Regexp
Ynon Perek
 
Regular Expressions(Theory of programming languages))
khudabux1998
 
Regular Expression Crash Course
Imran Qasim
 
Regular expression presentation for the HUB
thehoagie
 
CiNPA Security SIG - Regex Presentation
ThreatReel Podcast
 
Regular Expressions and You
James Armes
 
Regular expressions
Eran Zimbler
 
Week-2: Theory & Practice of Data Cleaning: Regular Expressions in Theory
Bertram Ludäscher
 
Regular Expressions
Akhil Kaushik
 
Regular Expressions 101
Kai Koenig
 
Regular expressions
Ignaz Wanders
 
Regular Expression
Syed Owais Ali Chishti
 
regex.ppt
ansariparveen06
 
Regular Expressions 101
Raj Rajandran
 
Regular Expressions 2007
Geoffrey Dunn
 
/Regex makes me want to (weep_give up_(╯°□°)╯︵ ┻━┻)/i (for 2024 CascadiaPHP)
brettflorio
 
OISF: Regular Expressions (Regex) Overview
ThreatReel Podcast
 
Regex Presentation
arnolambert
 
Regex Presentation
arnolambert
 
Ad

More from Svetlin Nakov (20)

PPTX
AI and the Future of Devs: Nakov @ Techniverse (Nov 2024)
Svetlin Nakov
 
PPTX
AI за ежедневието - Наков @ Techniverse (Nov 2024)
Svetlin Nakov
 
PPTX
AI инструменти за бизнеса - Наков - Nov 2024
Svetlin Nakov
 
PPTX
AI Adoption in Business - Nakov at Forbes HR Forum - Sept 2024
Svetlin Nakov
 
PPTX
Software Engineers in the AI Era - Sept 2024
Svetlin Nakov
 
PPTX
Най-търсените направления в ИТ сферата за 2024
Svetlin Nakov
 
PPTX
BG-IT-Edu: отворено учебно съдържание за ИТ учители
Svetlin Nakov
 
PPTX
Programming World in 2024
Svetlin Nakov
 
PDF
AI Tools for Business and Startups
Svetlin Nakov
 
PPTX
AI Tools for Scientists - Nakov (Oct 2023)
Svetlin Nakov
 
PPTX
AI Tools for Entrepreneurs
Svetlin Nakov
 
PPTX
Bulgarian Tech Industry - Nakov at Dev.BG All in One Conference 2023
Svetlin Nakov
 
PPTX
AI Tools for Business and Personal Life
Svetlin Nakov
 
PDF
Дипломна работа: учебно съдържание по ООП - Светлин Наков
Svetlin Nakov
 
PPTX
Дипломна работа: учебно съдържание по ООП
Svetlin Nakov
 
PPTX
Свободно ИТ учебно съдържание за учители по програмиране и ИТ
Svetlin Nakov
 
PPTX
AI and the Professions of the Future
Svetlin Nakov
 
PPTX
Programming Languages Trends for 2023
Svetlin Nakov
 
PPTX
IT Professions and How to Become a Developer
Svetlin Nakov
 
PPTX
GitHub Actions (Nakov at RuseConf, Sept 2022)
Svetlin Nakov
 
AI and the Future of Devs: Nakov @ Techniverse (Nov 2024)
Svetlin Nakov
 
AI за ежедневието - Наков @ Techniverse (Nov 2024)
Svetlin Nakov
 
AI инструменти за бизнеса - Наков - Nov 2024
Svetlin Nakov
 
AI Adoption in Business - Nakov at Forbes HR Forum - Sept 2024
Svetlin Nakov
 
Software Engineers in the AI Era - Sept 2024
Svetlin Nakov
 
Най-търсените направления в ИТ сферата за 2024
Svetlin Nakov
 
BG-IT-Edu: отворено учебно съдържание за ИТ учители
Svetlin Nakov
 
Programming World in 2024
Svetlin Nakov
 
AI Tools for Business and Startups
Svetlin Nakov
 
AI Tools for Scientists - Nakov (Oct 2023)
Svetlin Nakov
 
AI Tools for Entrepreneurs
Svetlin Nakov
 
Bulgarian Tech Industry - Nakov at Dev.BG All in One Conference 2023
Svetlin Nakov
 
AI Tools for Business and Personal Life
Svetlin Nakov
 
Дипломна работа: учебно съдържание по ООП - Светлин Наков
Svetlin Nakov
 
Дипломна работа: учебно съдържание по ООП
Svetlin Nakov
 
Свободно ИТ учебно съдържание за учители по програмиране и ИТ
Svetlin Nakov
 
AI and the Professions of the Future
Svetlin Nakov
 
Programming Languages Trends for 2023
Svetlin Nakov
 
IT Professions and How to Become a Developer
Svetlin Nakov
 
GitHub Actions (Nakov at RuseConf, Sept 2022)
Svetlin Nakov
 
Ad

Recently uploaded (20)

PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Horarios de distribución de agua en julio
pegazohn1978
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 

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("[email protected]")); console.log(emailPattern.test("[email protected]")); console.log(emailPattern.test("invalid@@mail")); console.log(emailPattern.test("err [email protected]")); 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