The FindSubString()
NWScript command locates one string within another.
Definition[]
int FindSubString (string sString, string sSubString
,
int nStart=0
)
string sString
- The string in which to search.
string sSubString
- The string to locate.
int nStart
- The character of sString at which to begin searching. This is zero-based, so the first character is 0, the second is 1, etc.
The returned value is the position of the first (leftmost) occurrence of sSubString
within sString
at or after the starting position. This value is zero-based, which means it could also be viewed as the number of characters in sString
to the left of the first occurrence of sSubString
. Using the third parameter does not affect how the return value should be interpreted; if the substring is found, then the returned value will be at least nStart
since that is where the search began.
If an error is encountered (such as the string not being found), −1 is returned.
The third parameter was added in patch 1.69.