Strings.matchGlobal()

Search a string using a global regular expression and return all matches.

This uses the `/g` modifier to find every match in the input string.

Usage

Hover over inputs/exits for more info.

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


// Search a string using a global regular expression and return all matches.

Strings.matchGlobal({

string: 'hello world',

regexp: 'l(\\w)',

caseInsensitive: true,

multiline: true,

}).execSync();

Inputs

string required

The string to search.

'hello world'
regexp required

The regular expression to match against.

'l(\\w)'
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 matches were found.

success

OK.

[ { found: 'll', at: 2, subgroups: [ 'l' ] } ]