bool = StrContains(sOne, sTwo, bCaseSensitive)
This macro function compares two strings, sOne and sTwo, and returns true if sOne contains sTwo, and false otherwise.
The inverse function is StrIsContained.
StrContains('A', 'Z', false); // false
StrContains('AAA', 'aaaa', false); // false
StrContains('AAAB', 'aaaa', false); // false
StrContains('A', 'a', false); // true
StrContains('Aaaa', 'aaaa', false); // true
The Boolean parameter, bCaseSensitive, determines if the comparison is to take note of uppercase and lowercase letters.
StrContains('A', 'Z', true); // false
StrContains('AAA', 'aaaa', true); // false
StrContains('AAAB', 'aaaa', true); // false
StrContains('A', 'a', true); // false
StrContains('Aaaa', 'aaaa', true); // false
Note that the functionality of this function can also be reproduced using the Pos and LowerCase functions.
if bCaseSensitive
bContains = Pos(sTwo,sOne) > 0
else
bContains = Pos(LowerCase(sTwo),LowerCase(sOne)) > 0
endif
See also: StrIsContained and StrCompare.
Topic 137000, last updated on 18-Apr-2020