Pattern matching with ranges Wildcards can match zero or more characters, but sometimes you may want to know whether a particular character falls within a range or characters. To do this, you can use ranges. For example, if you want to know whether a character is any letter, you could use the pattern [a-z] as follows: bu[a-z] This finds strings, such as but, bug, or bus, but not bu (not a three-character string). Of course, you don’t need to search for letters from a to z. You can just as well search for the following: bu[d-s] This regular expression finds bud and bus but not but (because the t lies out- side the range of letters from d to s). You can also use ranges to check whether a character falls within a numeric range, such as 21[0-9] This finds the strings 212 and 210.
If you only wanted to find strings with numbers between 4 and 7, you’d use this regular expression: 21[4-7] This finds the strings 215 but not the strings 210 or 218 because both 0 and 8 lie outside the defined range of 4–7.
This section shows a handful of regular expression symbols you can use to search for string patterns. A lot more regular expressions can perform all sorts of weird and wonderful pattern searching, so you can always find out more about these other options by browsing www.regular-expressions. info. By stringing multiple regular expression wildcards together, you can search for a variety of different string patterns.