From the course: Learning Regular Expressions
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Captures and backreferences - Regular Expressions Tutorial
From the course: Learning Regular Expressions
Captures and backreferences
- [Instructor] In this chapter, we will learn about capturing and how to use backreferences as to access the captures. In chapter five, we talked about grouping expressions with parentheses. Whenever you group an expression, the regex engine also captures it by default. It stores whatever text matches the grouped expression in memory for later use. Let's say we have a regex that starts with a, then inside parentheses ppl and then e at the end. Obviously it will match apple, but at the same time, the regex engine will capture ppl and remember it for later. It stores the actual data that was matched, not the expression. For example, if the parentheses had an expression to match either ppl or ngl, it would match angle and capture ngl or it would match apple and capture ppl. It doesn't matter if you were using these parentheses for repetition, for alternation, or just for your own organization. The regex engine will…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.