Function split

  • Splits string by separator.

    Note: This method is based on String#split.

    Parameters

    • Optional str: string

      The string to split.

      Optional
    • Optional separator: string | RegExp

      The separator pattern to split by.

      Optional
    • Optional limit: number

      The length to truncate results to.

      Optional

    Returns string[]

    Returns the string segments.

    Since

    5.0.0

    Example

    split('a-b-c', '-', 2)
    // => ['a', 'b']