Regex modifier

Regex modifier

Regex modifier

Function

Description of the flags supported by regex(pattern, flags). The current source code uses i, m, s to participate in compilation, and g is used by replace to determine whether to replace globally.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
patternStringNo''Regular body.
flagsStringNo''i ignores case; m multi-line; s dot matches newline; g is used for replace global replacement.

Return value

TypeDescription
RegexReturns a Regex object.

Example

Notes

  • g does not participate in regex compilation, and only controls the number of substitutions when Regex.replace and String.replace receive Regex.