How to compare a string with strings inside an array for a match?
I have a file in which each sentence (or word) (generally string) is present in a new line.
Opened the file and read the contents to a string.
private function readHandler(event:Event):void
{
_str = _readStream.readUTFBytes(_readStream.bytesAvailable);
_strArray = _str.split("
"); //contains each string that appears in a new line
_length = _strArray.length;
}
public function searchList(input:String):Boolean
{
_input = input;
_isFound = false;
for(i=0; i<_length; i++) {
if(_input == _strArray*) {
// trace("_input: "+_input+" _strArray["+i+"]: "+ _strArray*);
_isFound = true;
break;
} else {
_isFound = false;
continue;
}
}
if(_isFound)
return true;
else
return false;
}
But this doesn’t work. Seems like if(_input == _strArray*) never gets executed even if they are equal. What might be the problem. Is there some better way to so it?