User Tools

Site Tools


KeepBefore(text, string)

Returns characters before the first occurrence of specific string in text. Parameter string must not be empty. This function is case-sensitive.

Example Result
keepbefore( '5pm', 'pm' ) '5'
keepbefore('October 2015','2015') 'October '

The functions can have the optional third parameter with the index of the separator. The index can be negative - in this case, it's counted from the end of the text.

Example Result
keepbefore( 'a/b/c/d', '/', 2) 'a/b'
keepbefore( 'a/b/c/d', '/', -1) 'a/b/c'

See also

syntax/functions/keepbefore.txt · Last modified: 2021/03/23 19:08 by dmitry