User Tools

Site Tools


syntax:functions:keepbefore

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
syntax:functions:keepbefore [2015/03/27 14:05] elenapsyntax:functions:keepbefore [2021/03/23 19:07] dmitry
Line 1: Line 1:
 ====== KeepBefore(text, string) ====== ====== KeepBefore(text, string) ======
  
-Returns characters before the first occurrence of specific //'string'// in a given //'text'//. Case-sensitive. Parameter //string// must be not empty.+Returns characters before the first occurrence of specific //string// in //text//. Parameter //string// must not be empty
 +This function is case-sensitive
  
 ^  Example  ^  Result  ^ ^  Example  ^  Result  ^
 |  KeepBefore( '5pm', 'pm' )  |  '5'  | |  KeepBefore( '5pm', 'pm' )  |  '5'  |
 |  keepbefore('October 2015','2015' |  'October '  | |  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 === === See also ===
   * [[syntax:functions:keepafter]]   * [[syntax:functions:keepafter]]
   * [[syntax:functions:removestart]]   * [[syntax:functions:removestart]]
syntax/functions/keepbefore.txt · Last modified: 2021/08/14 22:09 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki