Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

karan karan
Web Development Techdegree Student 12,699 PointsHow /(\d*)(\d{2})/ this works
For example the number is 5347 but the first part (\d*) can capture all the 4 digits, so can it just skip the Second part (\d{2}) or the whole expressions evaluates which part to distribute to which section?
1 Answer

Brian Jensen
Treehouse StaffGreat question karan karan!
The two sets of parenthesis ()
are creating 2 capture groups. That way you can access the first 2 digits and the last 2 digits of that 4 digit string independently, with $1
and $2
.
karan karan
Web Development Techdegree Student 12,699 Pointskaran karan
Web Development Techdegree Student 12,699 PointsHello Brian Jensen, So this means the regex with 2 parenthesis, informs the parser to expect two stored groups right?
Brian Jensen
Treehouse StaffBrian Jensen
Treehouse StaffExactly karan karan