Last Occurrence of a character in a String in a CL

719 Views Asked by At

I have a requirement to find the last occurrence of a character in a string in CL. For Example, If I have a string as Test_01_abc.Txt , and I have to get the last occurrence of '_'(Underscore), I need to get answer as 8(Which is the position of the second Underscore in the string). I am using 7.2 Version and %SCANR is not working here. One way is to go in a loop and search it. Is there a better way? THanks

1

There are 1 best solutions below

3
On

%SCANR is an RPGLE built in function, not CLP. However, given that you are at v7.2, your only choce is to put QCLSCAN in a loop and find the last occurrance that way. There might be a way to do what you want in Python if you are willing to use that rather than CL.