StringInString() Function
- Last UpdatedFeb 21, 2017
- 1 minute read
Returns the first position of a specified string in another string.
Syntax
result = StringInString (string, searchfor, startpos, casesens)
Parameters
string
This is the string to searched. A literal string, message tagname, or string expression.
searchfor
This is the string that is to be searched for. A literal string, message tagname, or string expression.
startpos
This is the starting position in string of the search. A literal value, numeric tagname, or numeric expression.
casesens
Determines whether the search is case sensitive. Can be 0 or 1, discrete tagname, or Boolean expression.
0 - search is not case sensitive (uppercase and lowercase are considered the same).
1 - search is case sensitive (uppercase and lowercase are considered to be different).
Remarks
Use this function to determine if a certain string is contained in a message tag. You can specify the starting position for the search and whether the letter case is to be respected.
Example(s)
This script returns 5—because the first "M" in "MTX" is in the fifth position of the string:
StringInString("DBO MTX-010","MTX",1,0)
This script returns 3—because the first "M" in "MTX" is in the third position in the string:
StringInString("T-MTX 010 MTX","MTX",1,0)
This script returns 11—because the first "M" in "MTX" after the 8th position is in the 11th position in the string:
StringInString("T-MTX 010 MTX","MTX",8,0)
This script returns 11—because the first string that matches MTX in the correct case is in the 11th position:
StringInString("t-mtx 030 MTX", "MTX",1,1)
This script returns 0—because there is no "Mty" in the string:
StringInString("t-mtx 030 MTY-Mtx","Mty",1,1)