By using brackets, you can limit the valid characters in a format specification.
|
This specification... |
...means this |
| N[1357] |
One digit: 1, 3, 5, or 7. |
| N[1357](3) |
Three digits, each of which can be 1, 3, 5, or 7. |
| X[#]N[4] |
A "#" character and then 4. |
| X[AaBb] |
One character: A, a, B, or b. |
An exclusion symbol, "^", is available to disallow invalid characters. In order to disallow characters, the "^" symbol must be in the first position of the string. All characters following the "^" are disallowed.
If the "^" is not at the beginning of the string, then "^" is a valid character.
| A[^QVZ] |
Any letter of the alphabet except Q, V, or Z. |
| X[^*](2-4) |
Two to four characters; not an asterisk. |
| X[ #<^] |
One of three possible characters: "#", "<", or "^". |
| X[ #<^135] |
One of six possible characters: "#", "<", "^", 1, 3, or 5. |
| X[ #<^^] |
An invalid specification. |