Strings.takeUntilLast()
Syntax
function takeUntilLast(string: string, substring: string): string
Returns all characters in the string before the last 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.takeUntilLast(string, '.'); // -> "https://www.github"
Remarks
If the string does not contain the substring, this function returns the entire string.
Contrast Strings.skipUntilLast().
Compare Strings.takeUntil(),
Strings.takeUntilAfter(),
Strings.takeUntilAfterLast(),
and Strings.takeLast().