May 2011
Intermediate to advanced
1096 pages
40h 54m
English
RegExp.test() — test whether a string matches a pattern
regexp.test(string)
stringThe string to be tested.
true if
string contains text that matches
regexp; false otherwise.
TypeErrorIf this method is invoked on an object that is not a RegExp.
test() tests
string to see if it contains text that
matches regexp. If so, it returns
true; otherwise, it returns
false. Calling the test() method of a RegExp
r and passing it the string
s is equivalent to the following
expression:
(r.exec(s)!=null)
varpattern=/java/i;pattern.test("JavaScript");// Returns truepattern.test("ECMAScript");// Returns false
Read now
Unlock full access