Returns a Boolean value that indicates whether or not a pattern exists in a searched string.
SyntaxrgExp.test( str )
The following example illustrates the use of the test method. To use this example, pass the function a regular expression pattern and a string. The function will test for the occurrence of the regular expression pattern in the string and return a string indicating the results of that search:
function TestDemo(re, teststring)
{
var found = re.test(teststring)
var s = "";
s += "'" + teststring + "'"
if (found)
s += " contains ";
else
s += " does not contain ";
s += "'" + re.source + "'"
return(s);
}
Remarks
The test method checks to see if a pattern exists within a string and returns true if so, and false otherwise.
The properties of the global RegExp object are not modified by the test method.
See also Other articles AttributionsMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4