Skip to content

splitWithMatches

splitWithMatches(string, pattern) → array · String

Split a string by a pattern, keeping the matched parts as separate elements in the result.

  • string (required): the string to split

  • pattern (required): regex pattern to split on

utlx
splitWithMatches("hello123world456", "\\d+")
// ["hello", "123", "world", "456"]

Released under AGPL-3.0.