In addition to the flags and repetition quantifiers, there are many other characters that can be used to denote specific things. Positional indicators for example, can be used to state that a specific pattern should appear at the beginning or end of a string. A circumflex checks that the pattern is at the beginning of the string and a dollar sign is used to match the pattern at the end of a string:
var myRegxp = /^www/;
would output true whereas
var myRegxp = /www$/;
outputs false. As well as using the circumflex and dollar sign, escape codes can be used to check for other particular characters within strings.
Both parentheses and square brackets can be used to signify different things. First, standard brackets represent grouped characters and square brackets indicate a particular class of characters such as digits or letters. For example, if you wanted to match a pattern consisting of alphanumeric characters, you could use:
var myRegxp = /[0-9a-zA-Z]/
As the @ character is not an alphanumeric character, it would output false. Negative classes can also be used by making use again of the circumflex character within the square brackets. Negative classes specify what cannot be included, so by adding the circumflex inside the first square bracket, we can say that any character can be included except for alphanumeric characters:
var myRegxp = /[^0-9a-zA-Z]/
var myRegxp = /[\D\W]/;
which checks for any non-digit or any non-word characters. True is still the result. When using escaped character classes, a lowercase letter signifies that you're checking that the character does appear, and an upper case letter checks that it does not appear, so to check for numbers, use \d and to check for non-numbers, use \D. These shorthand escapes can be used to match numbers (or non-numbers), words (or non-words), and even whitespace (using \w) or non-whitespace (using \W) so you can see that most strokes of the keyboard can be validated in some way or another.