05. Capture

Groups

Groupings are used when you want to match certain patterns, but only want to extract part of the information.

We can later reference these segments that we captured later on.

To specify a grouping, use parantheses (()).

([cat])\s\1
Matches any string in text where "c c", "a a" or "t t"

Nested groups

You can also nest capture parentheses. The captured groups are in the order in which they are defined.

Referencing

To reference the captured substrings, use a backslash (\).

\0
matches full text
\1
group 1
\2
group 2

Learn how data is stored

Data Structures and Algorithms in Java

Learn how data is stored Try Data Structures

Algorithms are the procedures that software programs use to manipulate data structures. Besides clear and simple example programs, the author includes a workshop as a small demonstration program executable on a Web browser. The programs demonstrate in graphical form what data structures look like and how they operate.

$ Check price
64.9964.99Amazon 4.5 logo(97+ reviews)

More Data Structures resources

Build modern and responsive webpages

High Performance Web Sites

Build modern and responsive webpages Try Front-end

Want your web site to display more quickly? This book presents 14 specific rules that will cut 25% to 50% off response time when users request a page. Author Steve Souders, in his job as Chief Performance Yahoo!, collected these best practices while optimizing some of the most-visited pages on the Web.

$ Check price
29.9929.99Amazon 4.5 logo(63+ reviews)

More Front-end resources

Ad