@finch/regexp-split v1.0.8
:books: All guides and package documentation.
@finch/regexp-split
:bird: 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.
Installation
npm install -g @finch/regexp-split:bird: Omit -g flag to install within the current directory.
Params
pattern: a regular expression used to split thevalue.strict: when true thepatternmust be found in thevaluefor a split to be performed.
Examples
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": "/,/" }
}:bird: