You code is not complete, I don’t know where is spec declared and what is really reported as nil. But try if(!rexMatch(spec, me.name)) {…}
Or if you want to use match() method on string, then you should be aware the method does both simple string matching and regular expression matching depending on type of argument. If the pattern is plain string, then string matching is performed. You must insert pattern object for regular expression match. You can try something like me.name.match(R’your pattern here’). String prefixed with R makes a static RexPattern object for you.
Oh and maybe enumerating what should be in name instead of what shouldn’t could be shorter, try !rexMatch(’<^AlphaNum>’, me.name) or rexMatch(’^+$’, me.name). Character class includes not only ASCII, but all Unicode characters.
Wait, it worked once, and now giving errors. This is a slightly different section of code, but same issue. The error I’m getting is invalid comparison.
[code]commandArr = command.split(’ ');
if(rexMatch('<Digit>', commandArr[2]) > 0)
{
if(rexMatch('<Alpha>', commandArr[2]) > 0)
{
"NAN";
}
// End of spend mass points command
}[/code]
Invalid comparison is about your comparison with number zero “rexMatch(…) > 0”. Return value of rexMatch is a number when there is a match, but nil value otherwise and nil cannot be compared using arithmetic comparison operators. Just delete the “> 0” and you will be fine.