1.8 KiB
1.8 KiB
title | description | menu | weight | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
regexp.splitRegexp() function | `regexp.splitRegexp()` splits a string into substrings separated by regular expression matches and returns an array of `i` substrings between matches. |
|
101 |
regexp.splitRegexp()
splits a string into substrings separated by regular expression
matches and returns an array of i
substrings between matches.
Function type signature
(i: int, r: regexp, v: string) => [string]
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Parameters
r
({{< req >}})
Regular expression used to search v
.
v
({{< req >}}) String value to be searched.
i
({{< req >}}) Maximum number of substrings to return.
-1 returns all matching substrings.
Examples
Return an array of regular expression matches
import "regexp"
regexp.splitRegexp(r: /a*/, v: "abaabaccadaaae", i: -1)// Returns ["", "b", "b", "c", "c", "d", "e"]