From the course: Learning Regular Expressions

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Character ranges

Character ranges

- [Instructor] Now that we know about character sets, we can talk about character ranges. Cause character ranges are going to help us to work with character sets. First, let's take a look at a couple of character sets. If we had a character set that was to match any number we could define an inside square brackets as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. If we wanted to match any lowercase letter then we could create a character set and put all the lowercase letters A through Z inside. And if we wanted to match any uppercase letter we could do the same thing. But if we wanted to have a character set that would match any uppercase letter, any lowercase letter, or any number, you can see we would be writing out a lot of information. We'd have a very long regular expression and it would only be targeting a single character. That's crazy. Character ranges take the pain out of this. We use the metacharacter, which is just a dash or…

Contents