regex

regex

regex

Function

Compiles a regular expression and returns a Regex object.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
patternStringNo''Regular expression text.
flagsStringNo''Flag; i ignores case, m is multi-line, s matches newline with dot, and g is used for global replacement by replace.

Return value

TypeDescription
RegexReturns a regular object that can call test, match, and replace.

Example

Notes

  • A Chinese error is thrown when regular compilation fails.