Name
FindStr -- find a substring in a string
Synopsis
pos = FindStr(string$, substring$[, casesensitive, startpos, encoding])
Function
Searches for substring$ in string$ and returns the position of the substring. 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 casesensitive allows you to specify if the search should be case sensitive (defaults to True).

Starting with Hollywood 4.5, 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. Specifying 0 as the starting position means start searching from the beginning of the string. This is also the default.

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.

Inputs
string$
string to search in
substring$
string to find in string$
casesensitive
True for a case sensitive search (default) or False for a search not case sensitive
startpos
optional: starting position of the search operation in characters (defaults to 0) (V4.5)
encoding
optional: character encoding to use (defaults to default string encoding) (V7.0)
Results
pos
position of substring$ in string$ in characters or -1 if not found
Example
result = FindStr("Hello World!", "World")
Print(result)
This will print "6" which is the position of the first char "W".

Show TOC