Findstring from the End

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Findstring from the End

Post by Thunder93 »

To have mine continue further in with the negative searches, add just before the line;

Code: Select all

fResult = FindString(ReverseString(String), ReverseString(StringToFind) , StartPosition, Mode)
this;

Code: Select all

StartPosition = -StartPosition
Example: Debug FindString("Hello i'm KCC for ever", "o", -8)

:lol:
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Rinzwind
Enthusiast
Enthusiast
Posts: 679
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Findstring from the End

Post by Rinzwind »

Some kind of find reverse string procure should be included. First reversing the string is inefficient. Of course we can come up with 10 own solutions of various efficiency and stability, but this is a common operation that occurs too frequently to not be included in the product. Could just be an optional parameter in the existing findstring. Just keep counting chars left to right, but with search direction right to left.

Related, StringField could handle a negative index as right to left index...
Post Reply