views:

24

answers:

3

i love u how i know that i love u really contains u how find out it in actionscript?

+4  A: 

The indexOf method

Matthew Flaschen
A: 

exactly -1 when didn't find

hellowamerica
A: 

If you want to check for the existence of a word in strict sense (as a whole word, not part of another word), you can use regular expressions. For example, the string "hat" is contained in the string "I like that movie" as a substring but not as whole word. Use the String::match(pattern:*) method to search for regular expressions in a string.

var str:String = "I like that movie";
var t1:RegExp = /hat/;     // `/` is the delimiter
var t2:String = /\bhat\b/; // `\b` denotes word boundary
if(str.match(t1) != null)
  trace("hat is a substring");
if(str.match(t2) == null)
  trace("but hat is not present as whole word");
Amarghosh