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

Ace your Technical Interview

Algorithms

Ace your Technical Interview Try Algorithms

This fourth edition of Algorithms is the leading textbook on algorithms today and is widely used in universities worldwide. This book surveys the most important computer algorithms currently in use and provides a full treatment of data structures and algorithms for sorting, searching, graph processing, and string processing.

$ Check price
89.9989.99Amazon 4.5 logo(148+ reviews)

More Algorithms resources

Ad