Function matches

  • Returns all matches of regex in the string.

    Example

    import * as S from "flurp/string";

    const allVowels = S.matches(/[aeiou]/g);
    allVowels("weasel"); // ["e", "a", "e"]

    const oopsNotGlobal = S.matches(/[aeiou]/);
    oopsNotGlobal("weasel"); // null

    Parameters

    • regex: RegExp

      global flag must be set, or will return null

    Returns ((s: string) => undefined | RegExpMatchArray) | ((_: string) => null)