Strings.match()

Search a string using a regular expression and return the first match.

Usage

Hover over inputs/exits for more info.

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


// Search a string using a regular expression and return the first match.

Strings.match({

string: 'hello world',

regexp: 'w(\\w+)d',

caseInsensitive: true,

multiline: true,

}).execSync();

Inputs

string required

The string to search (i.e. "haystack").

'hello world'
regexp required

The regular expression to match against (i.e. "metal detector").

'w(\\w+)d'
caseInsensitive

Whether or not you care about uppercase/lowercase letters.

true
multiline

Whether to treat beginning and end characters (^ and $) as matching each line delimited by \n or \r.

true

Exits

error

An unexpected error occurred.

notFound

No match was found.

success

OK.

{ found: 'world', at: 6, subgroups: [ 'orl' ] }