go to previous page   go to home page   go to next page


Yes. This shows that any one out of a choice of several characters can match the transition.

Basic Regular Expressions: Choice

Rule 2.  Choice of Character

If you want to match one of several characters, place the characters inside square brackets, []. Any number of characters can be put inside the brackets, however the expression matches just one character at a time. For example, [abc] matches just one character, 'a' or 'b' or 'c'. Any number of bracketed groups can appear in a RE.

Regular ExpressionMatches Does Not Match
[wW] w W  wW [W ]
[abc] a b c ab ac c]
[dD]agmardagmar Dagmar   dDagmar agmar dAgMar
[abc]d[EFG]adE cdG bdF aE adg dEF

The characters inside the square brackets can appear in any order, but a given character should appear only once per set of brackets. So [abc] is equivalent to [cab]. The RE [aba] is a mistake, but will usually be regarded as equivalent to [ab].


Does [wW][hH][yY] match wHy ?

(There are no spaces in the regular expression; your web browser might not show this clearly.)