SlideShare a Scribd company logo
1 of 12
Javascript Regular Expressions @laserji 20110817
What is? A regular expression (regex or regexp for short) is a special text string for describing a search pattern.
Regex flavors .NET Java Javascript Perl POSIX PCRE Python Ruby …
Javascript’s Flavor No  or  anchors to match the start or end of the string. Use a caret or dollar instead. Lookbehind is not supported at all. Lookahead is fully supported. No atomic grouping or possessive quantifiers No Unicode support, except for matching single characters with No named capturing groups. Use numbered capturing groups instead. No mode modifiers to set matching options within the regular expression. No conditionals. No regular expression comments. Describe your regular expression with JavaScript // comments instead, outside the regular expression string.
Basics . – Matches any character, except for line breaks if dotall is false. * – Matches 0 or more of the preceding character. + – Matches 1 or more of the preceding character. ? – Preceding character is optional. Matches 0 or 1 occurrence.  – Matches any single digit  – Matches any word character (alphanumeric & underscore). [XYZ] – Matches any single character from the character class. [XYZ]+ – Matches one or more of any of the characters in the set. $ – Matches the end of the string. ^ – Matches the beginning of a string. [^a-z] – When inside of a character class, the ^ means NOT; in this case, match anything that is NOT a lowercase letter. {3,} – Limiting Repetition
Matching Modes /i makes the regex match case insensitive. /m enables "multi-line mode".  /g enables "global" matching. 
Advanced Character Classes/Sets [cat]  or  [^cat]  [+] Capture group & Backreference (capture)     (?:notcapture) Laziness & Greediness <a href=“#” title=“x”> <.*>,    <[^>]*>,    <.*?> Lookahead & Lookbehind (?=xxx) Unicode /00A5/.test('¥')   ->true
Javascript Methods String String.split() String.replace() String.search() String.match() RegExp RegExp.test() RegExp.exec()
Examples /{5}/.test(55555)   -> true ‘paipai’.replace(/i/g,’’)  -> ‘papa’ '#369'.replace(/()/g,'$1$1')   -> #336699 '12345'.replace(//g,function(match){ return match*2})   ->’246810’ 'abc'.replace(//,function(m){ return m.toUpperCase()} )   -> ‘Abc’ '123abc'.replace(/(+)+/g,function(match,capture1){ return capture1+'456'})   ->’123456’ '120X120'.split('X')[0]   ->120
Caution String.match() with /g String.split() with capture group ‘abc’.match(/(+)/)   vs.    ‘abc’.match(/()+/) Don’t be greedy
Tools https://addons.mozilla.org/en-US/firefox/addon/regular-expressions-tester/ http://gskinner.com/RegExr/ And:
Resoures http://regexlib.com/ http://www.regexlab.com/zh/ more on Google

More Related Content

What's hot

Regular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular ExpressionsRegular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular ExpressionsDanny Bryant
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrepTri Truong
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressionsBen Brumfield
 
Regular Expressions 101
Regular Expressions 101Regular Expressions 101
Regular Expressions 101Raj Rajandran
 
Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Sandy Smith
 
Regular expression
Regular expressionRegular expression
Regular expressionLarry Nung
 
Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Sandy Smith
 
Don't Fear the Regex WordCamp DC 2017
Don't Fear the Regex WordCamp DC 2017Don't Fear the Regex WordCamp DC 2017
Don't Fear the Regex WordCamp DC 2017Sandy Smith
 
Looking for Patterns
Looking for PatternsLooking for Patterns
Looking for PatternsKeith Wright
 
Regular Expressions 101
Regular Expressions 101Regular Expressions 101
Regular Expressions 101Kai Koenig
 
PERL Regular Expression
PERL Regular ExpressionPERL Regular Expression
PERL Regular ExpressionBinsent Ribera
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular ExpressionsJesse Anderson
 
Textpad and Regular Expressions
Textpad and Regular ExpressionsTextpad and Regular Expressions
Textpad and Regular ExpressionsOCSI
 

What's hot (20)

Regular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular ExpressionsRegular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular Expressions
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
 
Regular Expressions in Stata
Regular Expressions in StataRegular Expressions in Stata
Regular Expressions in Stata
 
Andrei's Regex Clinic
Andrei's Regex ClinicAndrei's Regex Clinic
Andrei's Regex Clinic
 
Regular Expressions 101
Regular Expressions 101Regular Expressions 101
Regular Expressions 101
 
Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Don't Fear the Regex LSP15
Don't Fear the Regex LSP15
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015
 
Don't Fear the Regex WordCamp DC 2017
Don't Fear the Regex WordCamp DC 2017Don't Fear the Regex WordCamp DC 2017
Don't Fear the Regex WordCamp DC 2017
 
Looking for Patterns
Looking for PatternsLooking for Patterns
Looking for Patterns
 
Regular Expressions 101
Regular Expressions 101Regular Expressions 101
Regular Expressions 101
 
Regex lecture
Regex lectureRegex lecture
Regex lecture
 
PERL Regular Expression
PERL Regular ExpressionPERL Regular Expression
PERL Regular Expression
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Textpad and Regular Expressions
Textpad and Regular ExpressionsTextpad and Regular Expressions
Textpad and Regular Expressions
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
Logic
LogicLogic
Logic
 

Viewers also liked

Js reg正则表达式
Js reg正则表达式Js reg正则表达式
Js reg正则表达式keke302
 
A www e o Ensino de Inglês
A www e o Ensino de InglêsA www e o Ensino de Inglês
A www e o Ensino de InglêsGarrasini
 
JavaScript Regular Expressions
JavaScript Regular ExpressionsJavaScript Regular Expressions
JavaScript Regular Expressions346682530
 
Pedar rozat mobarak
Pedar rozat mobarakPedar rozat mobarak
Pedar rozat mobarakTanha2011
 
Greener pastures seminar om iOS udvikling
Greener pastures seminar om iOS udviklingGreener pastures seminar om iOS udvikling
Greener pastures seminar om iOS udviklingJakob Mikkelsen
 
「オルタナティヴな専門家は可能か?」STS Network Japan シンポジウム 2011/06/18
「オルタナティヴな専門家は可能か?」STS Network Japan シンポジウム 2011/06/18「オルタナティヴな専門家は可能か?」STS Network Japan シンポジウム 2011/06/18
「オルタナティヴな専門家は可能か?」STS Network Japan シンポジウム 2011/06/18Sho KASUGA
 

Viewers also liked (8)

Js reg正则表达式
Js reg正则表达式Js reg正则表达式
Js reg正则表达式
 
A www e o Ensino de Inglês
A www e o Ensino de InglêsA www e o Ensino de Inglês
A www e o Ensino de Inglês
 
JavaScript Regular Expressions
JavaScript Regular ExpressionsJavaScript Regular Expressions
JavaScript Regular Expressions
 
Invitacionbarbacoafindesemana
InvitacionbarbacoafindesemanaInvitacionbarbacoafindesemana
Invitacionbarbacoafindesemana
 
Pedar rozat mobarak
Pedar rozat mobarakPedar rozat mobarak
Pedar rozat mobarak
 
Greener pastures seminar om iOS udvikling
Greener pastures seminar om iOS udviklingGreener pastures seminar om iOS udvikling
Greener pastures seminar om iOS udvikling
 
El Agua Potable
El Agua PotableEl Agua Potable
El Agua Potable
 
「オルタナティヴな専門家は可能か?」STS Network Japan シンポジウム 2011/06/18
「オルタナティヴな専門家は可能か?」STS Network Japan シンポジウム 2011/06/18「オルタナティヴな専門家は可能か?」STS Network Japan シンポジウム 2011/06/18
「オルタナティヴな専門家は可能か?」STS Network Japan シンポジウム 2011/06/18
 

Similar to JavaScript Regular Expressions Explained

Bioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introductionBioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introductionProf. Wim Van Criekinge
 
Coffee 'n code: Regexes
Coffee 'n code: RegexesCoffee 'n code: Regexes
Coffee 'n code: RegexesPhil Ewels
 
Php Chapter 4 Training
Php Chapter 4 TrainingPhp Chapter 4 Training
Php Chapter 4 TrainingChris Chubb
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionskeeyre
 
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_vancriekingeProf. Wim Van Criekinge
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Languagezone
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoobirbal
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming LanguageRaghavan Mohan
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de JavascriptBernard Loire
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsRaj Gupta
 
Regular Expression Crash Course
Regular Expression Crash CourseRegular Expression Crash Course
Regular Expression Crash CourseImran Qasim
 

Similar to JavaScript Regular Expressions Explained (20)

Bioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introductionBioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introduction
 
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
 
Bioinformatics p2-p3-perl-regexes v2014
Bioinformatics p2-p3-perl-regexes v2014Bioinformatics p2-p3-perl-regexes v2014
Bioinformatics p2-p3-perl-regexes v2014
 
Php Chapter 4 Training
Php Chapter 4 TrainingPhp Chapter 4 Training
Php Chapter 4 Training
 
Bioinformatica p2-p3-introduction
Bioinformatica p2-p3-introductionBioinformatica p2-p3-introduction
Bioinformatica p2-p3-introduction
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
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
 
Why Scala?
Why Scala?Why Scala?
Why Scala?
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Javascript
JavascriptJavascript
Javascript
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
Javascript
JavascriptJavascript
Javascript
 
PHP Regular Expressions
PHP Regular ExpressionsPHP Regular Expressions
PHP Regular Expressions
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular Expression Crash Course
Regular Expression Crash CourseRegular Expression Crash Course
Regular Expression Crash Course
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

JavaScript Regular Expressions Explained

  • 1. Javascript Regular Expressions @laserji 20110817
  • 2. What is? A regular expression (regex or regexp for short) is a special text string for describing a search pattern.
  • 3. Regex flavors .NET Java Javascript Perl POSIX PCRE Python Ruby …
  • 4. Javascript’s Flavor No  or anchors to match the start or end of the string. Use a caret or dollar instead. Lookbehind is not supported at all. Lookahead is fully supported. No atomic grouping or possessive quantifiers No Unicode support, except for matching single characters with No named capturing groups. Use numbered capturing groups instead. No mode modifiers to set matching options within the regular expression. No conditionals. No regular expression comments. Describe your regular expression with JavaScript // comments instead, outside the regular expression string.
  • 5. Basics . – Matches any character, except for line breaks if dotall is false. * – Matches 0 or more of the preceding character. + – Matches 1 or more of the preceding character. ? – Preceding character is optional. Matches 0 or 1 occurrence.  – Matches any single digit  – Matches any word character (alphanumeric & underscore). [XYZ] – Matches any single character from the character class. [XYZ]+ – Matches one or more of any of the characters in the set. $ – Matches the end of the string. ^ – Matches the beginning of a string. [^a-z] – When inside of a character class, the ^ means NOT; in this case, match anything that is NOT a lowercase letter. {3,} – Limiting Repetition
  • 6. Matching Modes /i makes the regex match case insensitive. /m enables "multi-line mode".  /g enables "global" matching. 
  • 7. Advanced Character Classes/Sets [cat] or [^cat] [+] Capture group & Backreference (capture) (?:notcapture) Laziness & Greediness <a href=“#” title=“x”> <.*>, <[^>]*>, <.*?> Lookahead & Lookbehind (?=xxx) Unicode /00A5/.test('¥') ->true
  • 8. Javascript Methods String String.split() String.replace() String.search() String.match() RegExp RegExp.test() RegExp.exec()
  • 9. Examples /{5}/.test(55555) -> true ‘paipai’.replace(/i/g,’’) -> ‘papa’ '#369'.replace(/()/g,'$1$1') -> #336699 '12345'.replace(//g,function(match){ return match*2}) ->’246810’ 'abc'.replace(//,function(m){ return m.toUpperCase()} ) -> ‘Abc’ '123abc'.replace(/(+)+/g,function(match,capture1){ return capture1+'456'}) ->’123456’ '120X120'.split('X')[0] ->120
  • 10. Caution String.match() with /g String.split() with capture group ‘abc’.match(/(+)/) vs. ‘abc’.match(/()+/) Don’t be greedy