From the course: Cert Prep: LPIC-1 Exam 101 (Version 5.0)

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Specifying occurrences with regexes

Specifying occurrences with regexes - Linux Tutorial

From the course: Cert Prep: LPIC-1 Exam 101 (Version 5.0)

Start my 1-month free trial

Specifying occurrences with regexes

- [Instructor] If we only had to match single characters we'd be done discussing regular expressions. But we often have to specify occurrences of characters. We talked a bit about this when we discussed extended globs. We have more power with regular expressions because we can be specific. We've already talked about how to match one character. We use a dot if we don't want to be specific about what type of character it is. If we want to specify, we can use character sets, character classes, or even just specify the character itself, such as a letter or a number. I will use the dot for these examples. If I want to match zero or one of any character I'd specify a question mark after the dot. This specifies how many of the previous character to match. In my case, I'm using a dot for my previous character, so it will match zero or one of any character. For instance, dog.? would match dog and dogs, as dog would be zero occurrences…

Contents