Say I have data like the following;
sequence_path (string: UTF-8): 1.2.3.4
As a result I wanted to fetch the parent from this sequence_path (i.e. '1.2.3').
In order to do so I wanted to do the following;
- Use a reverse search to find the position of the last '.' in the string,
- Fetch the (Left) substring up to the position of this last '.'
To perform the first step, I thought to use the FindString() string function (with a negative startIndex).
So, at first I thought that @FindString(@Value(sequence_path),.,-1) could be used. However, that returned '-1' (not found). However, somewhat unexpectedly at first, I noticed that '@FindString(@Value(sequence_path),.,-2) ' did return the desired value.
Upon second reading of the String Functions documentation: "If startIdx is a negative integer, FindString() returns the index in str starting at startIdx from the end of string , then matching strToFind going forward (from left to right)."
I now notice that the search is still from left to right (forward), however only from the negative index onward.
E.g. '@FindString(@Value(sequence_path),.,-3)', seems to look for a dot in '3.4', to find it in the second spot (index '1'), and then return 5 as the result (5 = 7-3+1 = StringLength + startIndex + matchIndex).
Is it possible to perform a reverse search (search from right to left) in a (non-Regex) StringSearcher function/transformer?
ps. from an efficiency perspective, I would like to avoid StringSearches that rely on Regular Expressions.