syntax:functions:keepbefore
This is an old revision of the document!
Table of Contents
KeepBefore(text, before_string)
Category: Text function
Description
This function returns characters before the first occurrence of before_string in text, if found. If before_string is not found within text and "empty" value is returned.
Alternative syntax
This function can take an optional third numeric parameter to define the instance of before_string used in the search. If instance_num is negative, the match starts from the end of text.
KeepBefore(text, before_string, instance_num)
Arguments
Argument | Type | Description |
---|---|---|
text | Text | The text value to search within for the after_string string. |
before_string | Text (must not be empty) | The text string to search for within text. The characters before this string are returned. |
instance_num* | Number (non-zero integer) | The occurrence of before_string to use as the delimiter to return the text following. |
*Optional argument.
Return value type: Text
Remarks
This function is case sensitive.
text and before_string are implicitly converted to text values if required.
Examples
keepbefore('5pm', 'pm') = '5' keepbefore('October 2015', '2015') = 'October ' //Note the space after 'October' is retained keepbefore('a/a/b/b/c/d', 'b/') = 'a/a/' //Second argument can be multiple characters keepbefore('a/b/c/d', '/', 2) = 'a/b' //Keep text before the second instance of '/' keepbefore('a/b/c/d', '/', -1) = 'a/b/c' //Keep text before the second instance of '/', from the end keepbefore('a/b/c/d', 'z') = (empty) //'z' not found within the text value
See also
syntax/functions/keepbefore.1627881762.txt.gz · Last modified: 2021/08/02 01:22 by craigt