The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Javascript Regular Expressions: Find Groups of Characters

Javascript Regular Expressions: Find Groups of Characters

4:35
In this lesson we'll capture groups of characters we wish to match, use quantifiers with those groups, and use references to those groups in String.prototype.replace.
Watch this lesson now
Avatar
egghead.io

In this lesson we'll capture groups of characters we wish to match, use quantifiers with those groups, and use references to those groups in String.prototype.replace.

Avatar
Piyush

I did not understand the application of ?: (non capturing of the capture group). When would I use this optimization?

Avatar
Joseph

As explained in the lesson, if you wanted to trim back on the memory allocated for storing the reference to the group you'd opt out. Perhaps you only wanted to utilize the alternation functionality, but did not need to reference the group later as expressed in something like:


var regex = /www\.google\.(?:com|net|org)/
regex.test('www.google.net') //true
regex.test('www.google.edu') //false

In reply to Piyush
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?