METHOD: RegExp.test
object.test([str])
This method tests for a match of a regular expression in a string, returning true
if successful, and false if not. The test method can be used with either a string
literal or a string variable. For example, the following code tests for a match of the regular
expression 'er' in the string "the fisherman", returning an appropriate message if a match is found
(which in this case it is).
Code:
rexp = /er/
if(rexp.test("the fisherman"))
document.write("It's true, I tell you.")
Output:
true
NOTE:
If no string is declared with this method, then the value of
RegExp.input is used.
|