removeBefore

Removes the part of the input string before the specified target.

Usage Scenarios

  • Text Cleaning: In text processing, remove unnecessary content before a specific position or keyword.
  • Data Extraction: Extract a part of the string after a certain point.

Example

import { removeBefore } from 'funtool/string'

removeBefore('foo-bar', '-') // ✅ 'bar'
removeBefore('hello', 3) // ✅ 'lo'

Signature

function removeBefore(input: string, target: string | number): string

Parameters

  • input ( string ): The input string.
  • target ( string | number ): The index or substring before which to remove the content.

Returns

  • ( string ): A new string with the content before the target removed.