Regular Expressions Character classes The basics


Suppose we have a list of teams, named like this: Team A, Team B, ..., Team Z. Then:

  • Team [AB]: This will match either either Team A or Team B
  • Team [^AB]: This will match any team except Team A or Team B

We often need to match characters that "belong" together in some context or another (like letters from A through Z), and this is what character classes are for.