@jiminp/tooltool
    Preparing search index...

    Function substringBefore

    • Returns the substring before the first occurrence of the delimiter.

      Type Parameters

      • T extends string | null = null

      Parameters

      • s: Nullish

        String (or null/undefined) to find the substring of.

      • delimiter: string | RegExp

        Needle that marks where the cropped string should end.

      • Optionalon_missing: T

        Value to return when s is nullish or delimiter is not found (defaults to null).

      Returns T

      • The substring that precedes the first occurrence of delimiter.
      • on_missing if s is null/undefined or if the delimiter cannot be found.
      substringBefore("path/to/file.txt", '/');       // "path"
      substringBefore("abc123xyz", /\d+/); // "abc"
      substringBefore(undefined, ':'); // null
      substringBefore("no-needle", ':'); // null
      substringBefore("no-needle", ':', 'default'); // 'default'
      substringBefore(null, ':', ''); // ''
    • Returns the substring before the first occurrence of the delimiter.

      Type Parameters

      • T extends string | null = null

      Parameters

      • s: Nullable<string>

        String (or null/undefined) to find the substring of.

      • delimiter: string | RegExp

        Needle that marks where the cropped string should end.

      • Optionalon_missing: T

        Value to return when s is nullish or delimiter is not found (defaults to null).

      Returns string | T

      • The substring that precedes the first occurrence of delimiter.
      • on_missing if s is null/undefined or if the delimiter cannot be found.
      substringBefore("path/to/file.txt", '/');       // "path"
      substringBefore("abc123xyz", /\d+/); // "abc"
      substringBefore(undefined, ':'); // null
      substringBefore("no-needle", ':'); // null
      substringBefore("no-needle", ':', 'default'); // 'default'
      substringBefore(null, ':', ''); // ''