getRegExpSource()function

getRegExpSource(regexp: PossibleRegExp): string
ParamType
regexpPossibleRegExp
The regular expression or string source to read. required
Return
string
The string source of the regular expression.

Convert a regular expression to its string source.

  • If regexp is a string it is returned as-is, otherwise its .source is returned.

Examples

getRegExpSource(/abc/); // "abc"