Special Characters
in regular style, some characters have special usage: [ \ ^ $ . | ? * + ( ).
They are special because they are used to enhance the regular matching function. Don't try to memorize them, and when we've all used them, you can easily remember them.
to use a special character as an ordinary identity, you must escape it . In other words, you need to precede the backslash.
For example, we want to find the point ".". In a regular style, it represents all characters except the newline character.
So we need to escape it:
1 showmatch ("Chapter 5.1",/\d\.\d/) // 5.1
If not escaped, "\d.\d" will also match "5+1":
1 showmatch ("5+1 = 6",/\d.\d/) // 5+1
Parentheses are also special characters, so use "\ (") to match the opening parenthesis. The following example looks for a character followed by an opening parenthesis:
1 showmatch ("function g ()",/\w\ (/) // g (
The slash "/" is not a special character in the regular syntax, but if the argument is a slash "/", it must be escaped to "\ \" so that the JS parser knows that the character you want is "/" rather than the end of a regular formula.
For example:
1 showmatch ("/",/\//) // ' /'
Foreign language translation--javascript Tutorial--regular expression--(3)