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.
Greedy expressions - Regular Expressions Tutorial
From the course: Learning Regular Expressions
Greedy expressions
- [Instructor] In this movie, we won't introduce another meta character. Instead, we're going to talk about an important principle of how regular expressions work. Often the regular expression engine has to make choices about what it returns as a match. This becomes especially important once we use repetition expressions, because now our strings are of an indeterminate length, and they may match several different things. We need to understand how regular expression engines make that choice by default. Let's look at some examples, so we understand what the problem is. Let's say that I have a regular expression looking for some number of digits, some number of word characters, and some number of digits. And I want to apply it to a file name like this. Now, what would be returned? We know that on either side of the regular expression has to have some number of digits, but the number of word characters could be a lot of…
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.