NumberedPosBw

Declaration: NumberedPosBw (SubStr, MainStr: string; StartIx, Count: integer; IgnoreCase : boolean): integer;

The function NumberedPosBw returns the position of the Count'th occurrence of the substring SubStr in the string MainStr. The search of the substring is performed backwards, starting at the given start position and scanning the string from higher to lower indices. The parameter StartIx specifies the position of the MainStr where the backward search is to be started. If StartIx is greater than the length of MainStr it is automatically adjusted to the end of the string.

The search is not case sensitive if IgnoreCase is set to a TRUE value. The parameter Count defines the number of required occurrences of the substring. If no substring can be found under the specified conditions, the function returns a zero value.

Example: Given that the string variable astr contains the string 'halso_masl_13_67$x.js_1dk.asf' the statement NumberedPosBw ('_1',astr, 100, 2, true); returns the value 11 (the second last occurence of the substring '_1' is at position 11.


Last Update: 2020-Feb-07