I am creating a simple application and wanted to use a function to match any given regular expression to any given string, so I created the following function:
function validateStr(regexp:RegExp, strVal:String):Boolean{
if(regexp.exec(strVal)==null)
return false;
else
return true;
}
But I was wondering, can’t I simply replace it with
function validateStr(regexp:RegExp, strVal:String):Boolean{
return regexp.test(strVal);
}
I am relatively new to ActionScript, so I do not know if both would present the same behavior.