Skip to content

substringBefore

substringBefore(string, delimiter) → string · String

Return the part of a string before the first occurrence of a delimiter. Returns the full string if delimiter is not found.

  • string (required): the source string

  • delimiter (required): the delimiter to search for

utlx
substringBefore("user@example.com", "@") // "user"
substringBefore("no-delimiter", "@")     // "no-delimiter" (not found — returns all)

Also: substringBeforeLast("a.b.c.d", ".") returns "a.b.c".

Released under AGPL-3.0.