📚 All guides and package documentation.
🐦 Stability: 2 - Stable (added in 1.0.0)
Yields one or more values after splitting the string value
using a regular expression.
Regular expressions are capable of splitting strings on an enormous variety of conditions. Tools like regexr.com are an excellent resource for regular expression learing an testing.
Read more about regular expression handling in the Getting Started guide.
npm install -g @finch/regexp-split
🐦 Omit -g
flag to install within the current directory.
pattern
: a regular expression used to split thevalue
.strict
: when true thepattern
must be found in thevalue
for a split to be performed.
Split "0,1,2"
into 0
, 1
, and 2
values:
{
"use": "@finch/regex-split",
"params": { "pattern": "/,/g" }
}
Split "Hello World"
into "Hello"
and "World"
values:
{
"use": "@finch/regex-split",
"params": { "pattern": "/\\s+/g" }
}
By default the full value
will be yielded if the pattern
is not found in the value
. The example below will not find ,
in Hello World
and will yield Hello World
:
{
"use": "@finch/regex-split",
"params": { "pattern": "/,/" }
}
The example below will find ,
in Hello World,Goodnight Moon
and will yield Hello World
and Goodnight Moon
:
{
"use": "@finch/regex-split",
"params": { "pattern": "/,/" }
}
🐦