Function substringBeforeLast

  • Returns the substring before the last occurrence of the given separator (the separator is not returned)

    Parameters

    • Optionaltext: null | string

      the string to get a substring from

    • Optionalseparator: null | string

      the String to search for

    Returns string | undefined

    the substring before the last occurrence of the given separator

    substringBeforeLast("foo/bar/foo/bar", "/");    // 'foo/bar/foo'