Strings.takeUntil()
Syntax
function takeUntil(string: string, substring: string): string
Returns all characters in the string before the first occurrence of the substring.
Parameters | |
string
|
The string to take characters from. |
substring
|
The substring to find within |
Example
import { Strings } from 'potence';
const string = 'https://www.github.com';
Strings.takeUntil(string, '://'); // -> "https"
Remarks
If the string does not contain the substring, this function returns the entire string.
Contrast Strings.skipUntil()
.
Compare Strings.takeUntilAfter()
,
Strings.takeUntilLast()
,
and Strings.take()
.