I was trying to create code to format a number for “money” (9.99) and discovered that the StrRFind function is behaving exactly like the StrFind function.
If StrRFind works the way I think is should, it should scan the string for the specified target from the right to the left, but in fact it seems to be scanning from left to right.
My test case:
Change the scene variable dotTest1: set to StrRFind(“1.11”,".") - dotTest1 = 1
Change the scene variable dotTest2: set to StrRFind(“1.111”,".") - dotTest2 = 1
Change the scene variable dotTest3: set to StrRFind(“11.111”,".") - dotTest3 = 2
I expected the following;
dotTest1 = 2
dotTest2 = 3
dotTest3 = 3
Performing the tests using StrFind returns the same results as above (which would be correct scanning from left to right, using an ordinal counting system).
There is a misunderstood with the expression, strRFind return the position of the lastest occurence of your term is a string.
For example:
strRFind(“www.test.com”,“t”)
the value return 7, because it’s the lastest “t”. In fact the description is wrong.
You wish 4 as value right ? I ask for know what to do for have an expression like you think but we need work carefully for avoid to break the existing expression.
Bouh,
I found the functions but not the documentation. I was basing my logic on the InStr and InSrtRev functions from VB Excel macro code). Your www.test.com example is misleading because both strRFind and strFind will return 4 because there is a T 4 spaces (starting at 0) from either end of the string. If you change the string to “http://www.test.com” then strFind will return 11 and strRFind should return 4.
If the logic follows standard C++ protocols then all will be right in this small corner of the world.
Merci,
Art.