The use of regular in JavaScript requires attention to a pit inside the brackets, which is the meta-character problem within the brackets. I stepped on the pit, online search and a lot of people stepped on the pit, so probably say a bit.
The brackets are called character groups (Character Class) in the regular, some are translated into character classes , and others are translated into character sets . I think the character group is better, after all, class in the computer belongs to the object-oriented "class." As the name implies, a character group is a set of characters that represent multiple characters that may appear in one place. Note that this emphasis only matches one location. (This paragraph was excerpted from-http://www.cnblogs.com/snandy/p/3662423.html)
Use a place to take any character, and then use the [. \n]* result Test to return true, but not in the context of the specific ... Gee, I can't understand.
A decisive test of var TESTP =/xx>[.\n]*/testp.test ("XX>ASDFDFASD"); Decisive or true, put "xx>" Back is also true, but both sides are put on is false. What is this for??????
Then re-put the var TESTP =/(xx>[.\n]*)/This, change the parentheses to catch a matching string . Test finished,regexp.$1 to find out is empty .... is empty .... Why????
When the string parameter of test becomes ("..."), this dot appears, so, the inside of this bracket is only the point, not the other, not the meta-character except \ n the meaning of single characters. So I searched the internet for a moment:
"A lot of metacharacters have become ordinary characters within a character group." it becomes a normal character instead of a meta character, and there are other like "?", "+", "*" which once placed in brackets also become ordinary characters.
So the pit still has to be careful ....
By the right, any character can be replaced with [\s\s].
The "pit" of the brackets in the JavaScript regular expression