VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-regexp-test-method/

⇱ JavaScript RegExp test() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript RegExp test() Method

Last Updated : 11 Jul, 2025

The RegExp test() Method in JavaScript is used to test for match in a string. If there is a match this method returns true else it returns false.


Output
true

Syntax

RegExpObject.test(str)

Where str is the string to be searched. This is required field.

Example 1: Searching for the string "computer" in the original string.  


Output
true

Example 2: Searching for the string "GEEK" in the original string. 


Output
false

Supported Browsers

  • Chrome
  • Safari
  • Firefox
  • Opera
  • Edge

We have a complete list of Javascript RegExp expressions, to check those please go through this JavaScript RegExp Complete Reference article.

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through

Comment