FeaturedIT topics

RegEx tutorial: Matching sets of characters

In this lesson, you’ll learn how to use RegEx (regular expressions) to work with sets of characters. Unlike the ., which matches any single character , sets enable you to match specific characters and character ranges.

Matching one of several characters

As you learned in the previous lesson, . matches any one character (as does any literal character). In the final example in that lesson, .a was used to match both na and sa, . matched both the n and s. But what if there was a file (containing Canadian sales data) named ca1.xls as well, and you still wanted to match only na and sa)? . would also match c, and so that filename would also be matched.

Text

sales1.xls
orders3.xls
sales2.xls
sales3.xls
apac1.xls
europe2.xls
na1.xls
na2.xls
sa1.xls
ca1.xls

Related Articles

Back to top button