Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 如何检查字符串是否包含certion word actionscript?_Actionscript 3 - Fatal编程技术网

Actionscript 3 如何检查字符串是否包含certion word actionscript?

Actionscript 3 如何检查字符串是否包含certion word actionscript?,actionscript-3,Actionscript 3,如何检查字符串是否包含certion word actionscript?方法方法如果要严格检查单词是否存在(作为整个单词,而不是另一个单词的一部分),可以使用正则表达式。例如,字符串“hat”包含在字符串“I like that movie”中,作为子字符串而不是整个单词。使用该方法搜索字符串中的正则表达式 var str:String = "I like that movie"; var t1:RegExp = /hat/; // `/` is the delimiter var t

如何检查字符串是否包含certion word actionscript?

方法

方法

如果要严格检查单词是否存在(作为整个单词,而不是另一个单词的一部分),可以使用正则表达式。例如,字符串
“hat”
包含在字符串
“I like that movie”
中,作为子字符串而不是整个单词。使用该方法搜索字符串中的正则表达式

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");

如果要检查严格意义上的单词是否存在(作为整个单词,而不是另一个单词的一部分),可以使用正则表达式。例如,字符串
“hat”
包含在字符串
“I like that movie”
中,作为子字符串而不是整个单词。使用该方法搜索字符串中的正则表达式

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");
请注意,RegExp::test(string:string)将返回一个布尔值,从而删除与null的比较。例如:如果(t1.test(str)){…}只是一个注释,RegExp::test(string:string)将返回一个布尔值,从而删除与null的比较。例:if(t1.test(str)){…}