From the course: Bash Patterns and Regular Expressions

Unlock the full course today

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

Specifying occurrences

Specifying occurrences - Bash Tutorial

From the course: Bash Patterns and Regular Expressions

Start my 1-month free trial

Specifying occurrences

- [Instructor] If we only had to match single characters, we'd be done discussion 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 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 dot question mark would match dog and dogs as dog would be zero occurrences of the preceding character, and dogs would…

Contents