Skip to content

substringBefore ​

Returns the substring before the first occurrence of the character sequence chars in str.

Type: transform

Parameters ​

  • input (unknown): The input string.
  • chars (unknown): The character sequence to search for.

Returns ​

Type: string

The substring before the first occurrence of the character sequence chars in str.

Examples ​

javascript
substringBefore("hello world", " ") // "hello"

Released under the MIT License.