ReverseFindStr -- find a substring in a string in reverse (V9.0)
pos = ReverseFindStr(string$, substring$[, casesen, startpos, encoding])
Searches for substring$ in string$ and returns the position of the substring. In contrast to FindStr(), searching is done in reverse, i.e. from the string's end to its start.

The position is returned in characters, not in bytes, starting at position 0 for the first character. If substring$ cannot be found, -1 is returned. The optional argument casesen allows you to specify if the search should be case sensitive. This defaults to the global case sensitive default mode set using IgnoreCase(). See IgnoreCase for details.

You can also specify a starting position for the search in the optional argument startpos. This position needs to be specified in characters, not in bytes. By default, startpos is set to the length of string$ in characters minus 1.

The optional encoding parameter can be used to set the character encoding to use. This defaults to the default string encoding set using SetDefaultEncoding(). See Character encodings for details.

string to search in
string to find in string$
True for a case sensitive search or False for a case insensitive search; the default is True or whatever default has been set using the IgnoreCase() command
optional: starting position of the search operation in characters (defaults to the length of string$ minus 1)
optional: character encoding to use (defaults to default string encoding)
position of substring$ in string$ in characters or -1 if not found
result = ReverseFindStr("Hello, Hello!", "Hello")
This will print "7" because searching is done in reverse, which is why the position of the second "Hello" is returned.

Show TOC