Strings.isValidRegex()

Determine whether or not the input string constitutes a valid regular expression.

Regular expressions should be provided without leading or trailing slashes, and without any modifiers like `m` or `i`.

Usage

Hover over inputs/exits for more info.

var Strings = require('machinepack-strings');


// Determine whether or not the input string constitutes a valid regular expression.

Strings.isValidRegex({

string: 'h(e\\w)+llo w[ou]rld',

}).execSync();

Inputs

string required

The string to test as a regular expression.

'h(e\\w)+llo w[ou]rld'

Exits

error

An unexpected error occurred.

success

OK.

true