Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "string/substring-before/docs/types/index.d"

Index

Functions

Functions

Export assignment substringBefore

  • substringBefore(str: string, search: string): string
  • Returns the part of a string before a specified substring.

    Parameters

    • str: string

      input string

    • search: string

      search string

    Returns string

    substring

    Example

    var out = substringBefore( 'beep boop', ' ' );
    // returns 'beep'

    Example

    var out = substringBefore( 'beep boop', 'p' );
    // returns 'bee'

    Example

    var out = substringBefore( 'Hello World!', '' );
    // returns ''

    Example

    var out = substringBefore( 'Hello World!', 'XYZ' );
    // returns 'Hello World!'