Check if string contains pattern using .test

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

test reports whether the pattern matches. [a-z]+ matches one or more lowercase ASCII letters, so this logs Match exists. A global regular expression remembers lastIndex, so repeated test calls on the same regexp can skip ahead or return false until lastIndex wraps.

Feedback about page:

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



Table Of Contents