MyChat Scripts Engine: IsStringInList
Searching a substring in a string list that has delimiters between its elements.
Syntax
function IsStringInList(sWhat, sStringList, sDelimiter: string; bIgnoreCase: boolean): boolean;
Parameters and return values
Parameter |
Type |
Value |
sWhat |
string |
substring that you need to find; |
sStringList |
string |
source string for searching; |
bIgnoreCase |
boolean |
true ignore the letter case, false the difference between letters case does not matter. |
Most MSL functions, which return a text string with a list of elements, have the "|" symbol as the delimiter. However, you can use any delimiters both from one or several symbols.
Function result
True, if the specified element exists in the source string between delimiters.
Example
const
sFirst = 'Blue|Red|Green|';
sSecond = 'John Carpenter,Ivan Dulin,Sara Connor';
begin
mLogScript('Original string "' + sFirst + '"', '');
if IsStringInList('red', sFirst, '|', true) then mLogScript('"red" found', '')
else mLogScript('"red" not found', '');
mLogScript('Original string "' + sSecond + '", case sensitive search', '');
if IsStringInList('sara connor', sSecond, ',', false) then mLogScript('"sara connor" found', '')
else mLogScript('"sara connor" not found', '');
end.
Script work result
[16:08:24] (Log "IsStringInList"): Original string "Blue|Red|Green|"
[16:08:24] (Log "IsStringInList"): "red" found
[16:08:24] (Log "IsStringInList"): Original string "John Carpenter,Ivan Dulin,Sara Connor", case sensitive search
[16:08:24] (Log "IsStringInList"): "sara connor" not found