substring

Extracts a substring from the str between the start and end indices.

Usage Scenarios

  • Text Extraction: In text processing, extract a specific part of a string.
  • Data Parsing: Parse data by extracting relevant substrings.

Example

import { substring } from 'funtool/string'

substring('hello world', 0, 5); // ✅ 'hello'

Signature

function substring(str: string, start: number, end: number): string

Parameters

  • str ( string ): The input string.
  • start ( number ): The starting index.
  • end ( number ): The ending index.

Returns

  • ( string ): The extracted substring.