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 - Bash Tutorial
From the course: Bash Patterns and Regular Expressions
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…
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.
Contents
-
-
-
-
-
-
(Locked)
What are regular expressions?2m 35s
-
(Locked)
Why aren't regexes consistent?1m 30s
-
(Locked)
Basic vs. Extended Regular Expressions3m 38s
-
(Locked)
Regex support in command line tools57s
-
(Locked)
Matching characters and words3m 21s
-
(Locked)
Specifying occurrences1m 56s
-
(Locked)
Alternation and grouping3m 21s
-
(Locked)
Back references and subexpressions1m 48s
-
(Locked)
-
-
-
-
-