Check if string contains pattern using .test

suggest change
var re = /[a-z]+/;
if (re.test("foo")) {
    console.log("Match exists.");
}

The test method performs a search to see if a regular expression matches a string. The regular expression [a-z]+ will search for one or more lowercase letters. Since the pattern matches the string, “match exists” will be logged to the console.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents