I'm a FLEX newbie, but an experienced Lingo programmer.
I'm trying to figure out the syntax for comparing whether or
not one string contains all or part of another.
For example in Lingo:
"if varString1 contains varString2 then do something"
I have a bit of code in FLEX that reads:
if (item.lastName == filterInput.text)
which checks if an item in an array called "lastName" is
identical to the text in a text input field.
This will then filter a data grid to contain only the items
that match (==).
But what I want is to check if (item.lastName contains
filterInput.text), such as "Does catacomb contain 'cat' ".
I can't seem to find an operator to do this. Any help is
As rightly suggested by atta707, you can use indexOf, match
or search methods of Flex String class.
Following is code that uses search method of the String
private function containsPattern(searchIn:String,
if(pattern is String || pattern is RegExp)
var found:Boolean = false;
search function returns 0 if pattern not found, first index
of the pattern otherwise.
var foundAt:Number = searchIn.search(pattern);
if(foundAt > 0)
found = true;
throw new Error("pattern must be either String or RegExp