Meta Engineer?

This is available as Regex\split in the www repository.

Splits $haystack into chunks by its substrings that match with $pattern

namespace HH\Lib\Regex;

function split(
  string $haystack,
  Pattern<Match> $delimiter,
  ?int $limit = NULL,
): vec<string>;

If $limit is given, the returned vec will have at most that many elements. The last element of the vec will be whatever is left of the haystack string after the appropriate number of splits. If no substrings of $haystack match $delimiter, a vec containing only $haystack will be returned. The regex pattern follows the PCRE library: https://www.pcre.org/original/doc/html/pcresyntax.html.

Throws InvariantException if $limit < 2.



  • string $haystack
  • Pattern<Match> $delimiter
  • ?int $limit = NULL


  • vec<string>