JS: RegExp.prototype.test

By Xah Lee. Date: . Last updated: .

regex.test(string)

Return true if regex match part or whole of string, else false.

// example of RegExp “test” method
// check if a string match

const gx = RegExp ("4");

console.log ( gx.test ("345")); // true
console.log ( gx.test ("999")); // false

Reference

ECMAScript® 2016 Language Specification#sec-regexp.prototype.test

RegExp Topic

  1. JS: RegExp Tutorial
  2. JS: RegExp Syntax
  3. JS: Regex Find/Replace
  4. JS: RegExp Object
  5. JS: RegExp Constructor
  6. JS: RegExp.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS Basics
  4. JS in Depth
  5. JS Reference
  6. DOM
  7. SVG
  8. JS Misc