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
let 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: String Methods for RegExp
  3. JS: RegExp Object
  4. JS: RegExp Constructor
  5. JS: RegExp.prototype
  6. JS: RegExp Syntax
Like what you read? Buy JavaScript in Depth