Regular characters/
Meaning: For a character, it is usually indicated by literal meaning that the character followed by a special character is not interpreted.
For example:/b/matches the character ' B ', which becomes a special character by adding a backslash before B, i.e./b/, which means
Match the dividing line of a word.
Or:
For a few characters, usually the description is special, indicating that the character immediately followed is not special, but should be interpreted literally.
For example: * is a special character that matches any character (including 0 characters), for example:/a*/means matching 0 or more aces. To match the literal *, precede a with a backslash; For example:/a*/matches a ' * '.
Character ^
Meaning: The character that matches must be at the front.
For example:/^a/does not match the ' a ' in ' an A ', but matches ' an A. ' The "A" in the front.
Character $
Meaning: Similar to ^, matches the last character.
For example:/t$/does not match ' t ' in ' eater ', but matches ' t ' in ' eat '.
Characters
Meaning: matches the characters of the preceding 0 or n times.
For example:/bo*/matches ' B ' in ' boooo ' or ' a bird warbled ' in ' a ghost booooed ', but does not match ' agoat g
runted any character in the ".
Character +
Meaning: Matches the character preceded by the + number 1 or n times. Equivalent to {1,}.
For example:/a+/matches ' a ' and ' Caaaaaaandy ' in ' Candy '. All ' a ' in.
Character?
Meaning: match the preceding character 0 or 1 times.
For example:/e?le?/matches ' el ' and ' angle ' in ' Angel '. ' Le ' in the.
Character.
Meaning: (decimal point) matches all individual characters except for line breaks.
For example:/.n/matches ' an ' and ' on ' in the ' nay ', an apple are on the tree, but does not match ' nay '.
Character (x)
Meaning: Matches ' X ' and records the matching value.
For example:/(foo)/Match and record "Foo bar." In the ' foo '. The matching substring can be in the result array of the element [1], ..., [n] Return
Back, or the properties of the object being RegExp, ..., returned.
Character X│y
Meaning: Match ' x ' or ' Y '.
For example:/green│red/matches ' green ' and ' Red apple ' in ' green apple '. In the ' Red '.
Character {n}
Meaning: Here The n is a positive integer. Matches the preceding n characters.
For example:/a{2}/does not match "candy," in ' a ', but matches "Caandy," in all ' a ' and ' Caaandy. ' In front of the two ' a '.
Character {n,}
Meaning: Here The n is a positive integer. Matches at least n preceding characters.
For example:/a{2,} does not match ' a ' in ' Candy ', but matches all ' a ' and ' Caaaaaaandy ' in ' Caandy '. All ' a ' in the
Character {n,m}
Meaning: Here the N and M are all positive integers. Matches at least n up to m preceding characters.
For example:/a{1,3}/does not match any character in "Cndy", but matches the front two in "a", "Candy," in "Caandy,"
"A" and "Caaaaaaandy" in front of the three ' a ', note: even if "caaaaaaandy" there are many ' a ', but only match the preceding three ' a ' that is ' AAA '.
character [XYZ]
Meaning: A list of characters that matches any one of the characters listed. You can indicate a range of characters through hyphens.
For example: [ABCD] is the same as [a-c]. They match the ' C ' in ' B ' and ' ache ' in ' brisket '.
character [^XYZ]
Meaning: A character complement, that is, it matches everything except the characters listed. You can use hyphens--to indicate a range of characters.
For example: [^ABC] and [^a-c] are equivalent, they first match the ' R ' and ' chop ' in ' brisket '. In the ' H '.
Character
Meaning: Match a space (do not confuse with B)
Character B
Meaning: Match the dividing line of a word, such as a space (not with confusion)
For example:/bnw/matches ' no ' in ' Noonday ',/wyb/matches ' possibly yesterday. ' In the ' ly '.
Character B
Meaning: A non-dividing line that matches a word
For example:/wbn/matches ' on ' in ' Noonday ',/ybw/matches ' possibly yesterday. ' In the ' ye '.
Character CX
Meaning: Here The X is a control character. Matches the control character of a string.
For example:/cm/matches the control-m in a string.
Character D
Meaning: Matches a number, equivalent to [0-9].
For example:/d/or/[0-9]/matches "B2 is the" suite number. In the ' 2 '.
Character D
Meaning: Matches any non-numeric, equivalent to [^0-9].
For example:/d/or/[^0-9]/matches "B2 is the" suite number. In the ' B '.
Character F
Meaning: matches a form character
Character N
Meaning: matches a newline character
Character R
Meaning: matches a carriage return character
Character S
Meaning: Matches a single white spaces, including spaces, tab,form feeds, line breaks, equivalent to [FNRTV].
For example:/sw*/matches "foo bar." ' Bar ' in the.
Character S
Meaning: matches a single character except white spaces, equivalent to [^ FNRTV].
For example:/s/w* matches "foo bar." In the ' foo '.
Character T
Meaning: Match a tab
Character V
Meaning: Match a head tab
Character W
Meaning: Matches all numbers and letters and underscores, equivalent to [a-za-z0-9_].
For example:/w/matches the ' a ', '. 28, ' in ' 5 ' and ' 3D ' in ' apple '. In the ' 3 '.
Character W
Meaning: Matches other characters except numbers, letters, and underscores, equivalent to [^a-za-z0-9_].
For example:/w/or/[^ $A-za-z0-9_]/match "50%." In the '% '.
Character N
Meaning: Here The n is a positive integer. Matches the value of N of the last substring of a regular expression (counting the left parenthesis).
For example:/apple (,) sorange1/match "Apple, orange, cherry, peach." In the ' Apple, Orange ', here is a more complete example.
Note: If the number in the left parenthesis is smaller than the number specified in N, then N takes a row of octal escape as a description.
Character Ooctal and Xhex
Meaning: Here the ooctal is a octal escape value, and Xhex is a hexadecimal escape value that allows ASCII code to be embedded in a regular expression
Attached: The following table is a complete list of metacharacters and its behavior in the context of regular expressions:
Character description
\
Marks the next character as a special character, or a literal character, or a back reference, or a octal escape character. For example, ' n ' matches the character ' n '. ' \ n ' matches a newline character. Sequence ' \ ' matches ' and ' \ (' Matches ' (".
^
Matches the start position of the input string. If the Multiline property of the RegExp object is set, ^ also matches the position after ' \ n ' or ' \ R '.
$
Matches the end position of the input string. If the Multiline property of the RegExp object is set, the $ also matches the position before ' \ n ' or ' \ R '.
*
Matches the preceding subexpression 0 or more times. For example, zo* can match "z" and "Zoo". * is equivalent to {0,}.
+ matches the preceding subexpression one or more times. For example, ' zo+ ' can match "Zo" and "Zoo", but cannot match "Z". + is equivalent to {1,}.
?
Match the preceding subexpression 0 times or once. For example, "Do (es)" can match "do" in "do" or "does". is equivalent to {0,1}.
N
n is a non-negative integer. Matches the determined n times. For example, ' o{2} ' cannot match ' o ' in ' Bob ', but can match two o in ' food '.
{N,}
n is a non-negative integer. Match at least n times. For example, ' o{2,} ' cannot match ' o ' in ' Bob ' but can match all o in ' Foooood '. ' O{1,} ' is equivalent to ' o+ '. ' O{0,} ' is equivalent to ' o* '.
{N,m}
M and n are nonnegative integers, of which n <= M. Matches n times at least and matches up to M times. Liu, "o{1,3}" will match "Fooooood