From the course: Learning Regular Expressions

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Non-capturing group expressions

Non-capturing group expressions

- [Instructor] In this movie, we will learn about non-capturing group expressions. Grouped expressions are automatically captured by default. We've seen that. However, we can prevent that automatic capture from taking place. This can be useful if we know that we're not going to need a backreference to it. It frees up storage for other captures. If we have an expression that has a lot of groups, we might end up with more than nine captures and more than nine backreferences. Or it can be awkward to just pick out the backreferences you want, like one, four, and nine. If we suppress capturing the ones we don't need, we can simplify it and just use 1, 2, 3 instead. Skipping unnecessary data storage may improve the speed of searches that you probably won't notice it unless the search is large or complex. You can use non-capturing groups in most regular expression engines, but not in the early versions that are in…

Contents