Javascript provides a Regexp object to perform operations and functions on regular expressions. Each regular expression pattern corresponds to a Regexp instance. You can create an instance of the Regexp object in two ways.
Use Regexp's explicit constructor. Syntax: New Regexp ("pattern" [, "Flags"]).
Use Regexp's implicit constructor in plain text format:/pattern/[flags].
The pattern part is required for the regular expression pattern text to be used. In the first method, the pattern part exists as a javascript string and must be enclosed by double quotation marks or single quotation marks. In the second method, the pattern part is nested between two, quotation marks are not allowed.
The flags part sets the Flag Information of the regular expression, which is optional. If the flags part is set, it exists as a string in the first method; in the second method, it follows the last "/" character in the text form. Flags can be a combination of the following flag characters.
G is the global flag. If this flag is set, the search and replacement operations on a text will take effect for all matching parts of the text. If this flag is not set, only the first matched content is searched and replaced.
I is a case-insensitive flag. If this flag is set, Case sensitivity is ignored during Matching and comparison.
M is a multiline flag. If this flag is not set, the metacharacter "^" only matches the start position of the searched string, the metacharacter "$" only matches the end position of the string to be searched. If this flag is set, "^" can also match the position after "\ n" or "\ r" in the searched string (that is, the beginning of the next row, "$" can also match the position after "\ n" or "\ r" in the searched string (that is, the end of the next row.
Code8.1 is an example of creating a regular expression.
Code 8.1 create a regular expression: 8.1.htm