Use regex.test() if all you want is a boolean result:

console.log(/^([a-z0-9]{5,})$/.test('abc1')); // false

console.log(/^([a-z0-9]{5,})$/.test('abc12')); // true

console.log(/^([a-z0-9]{5,})$/.test('abc123')); // true

...and you could remove the () from your regexp since you've no need for a capture.

Answer from user113716 on Stack Overflow
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ RegExp โ€บ test
RegExp.prototype.test() - JavaScript | MDN
This example tests if "hello" is contained at the very beginning of a string, returning a boolean result. ... function testInput(re, str) { const midString = re.test(str) ? "contains" : "does not contain"; console.log(`${str} ${midString} ${re.source}`); } When a regex has the global flag set, ...
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_regexp_test.asp
JavaScript RegExp test() Method
cssText getPropertyPriority() ... RegExp Methods Next โฏ ยท Search a string for the character "e": let text = "The best things in life are free"; let pattern = /e/; let result = pattern.test(text); Try it Yourself ...
๐ŸŒ
Regex101
regex101.com
regex101: build, test, and debug regex
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.
๐ŸŒ
Mozilla
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Guide โ€บ Regular_expressions
Regular expressions - JavaScript | MDN
js ยท /\p{L}*/u; Unicode regular expressions have different execution behavior as well. RegExp.prototype.unicode contains more explanation about this. Note: Several examples are also available in: The reference pages for exec(), test(), match(), matchAll(), search(), replace(), split() The guide articles: character classes, assertions, groups and backreferences, quantifiers ยท
๐ŸŒ
RegExr
regexr.com
RegExr: Learn, Build, & Test RegEx
Regular expression tester with syntax highlighting, PHP / PCRE & JS Support, contextual help, cheat sheet, reference, and searchable community patterns.
๐ŸŒ
Regular-Expressions.info
regular-expressions.info โ€บ javascriptexample.html
JavaScript RegExp Example: Online Regular Expression Tester
<SCRIPT LANGUAGE="JavaScript"><!-- function demoMatchClick() { var re = new RegExp(document.demoMatch.regex.value); if (document.demoMatch.subject.value.match(re)) { alert("Successful match"); } else { alert("No match"); } } function demoShowMatchClick() { var re = new RegExp(document.demo...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ javascript-regexp-test-method
JavaScript RegExp test() Method - GeeksforGeeks
July 11, 2025 - let str = "GeeksforGeeks : A computer science portal for geeks."; let regex = new RegExp("computer",); let rex = regex.test(str); console.log(rex); ... Example 2: Searching for the string "GEEK" in the original string.
Find elsewhere
๐ŸŒ
Regex Pal
regexpal.com
Regex Tester - Javascript, PCRE, PHP
Test your Javascript and PCRE regular expressions online.
๐ŸŒ
Softchris
softchris.github.io โ€บ pages โ€บ javascript-regex.html
Regex in JS - how YOU can learn it and learn to like it
The above RegEx fulfills all our ... a number at the end. Let's start to see if the incoming route matches: /\/products\/\d+$/.test('/products/112') // true /\/products\/\d+$/.test('/products/') // false...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ home โ€บ javascript โ€บ javascript regexp test
JavaScript RegExp Test
September 1, 2008 - In the following program, we are using the JavaScript RegExp.test() method to test whether the string matches a specified pattern ("\Hello*") defined by the regular expression within this string "Hello World".
๐ŸŒ
W3Resource
w3resource.com โ€บ javascript โ€บ object-property-method โ€บ regexp-test.php
JavaScript test() Method : RegExp Object - w3resource
<![CDATA[ // Create a new RegExp object. newRe = new RegExp('Fox','g') // Define a string. str1 = 'The Quick Brown Fox Jumps Over The Lazy Dog'; // Check whether regular expression exists in the string. if (newRe.test(str1)) { document.write("'Fox' ...
๐ŸŒ
Built In
builtin.com โ€บ software-engineering-perspectives โ€บ javascript-regex
A Guide to JavaScript Regular Expressions (RegEx) | Built In
An example of regex in JavaScript could be checking if a match for the character pattern "apple" exists within the string "apple tree". To test this, you could use the RegExp.prototype.test() method below:
๐ŸŒ
SitePoint
sitepoint.com โ€บ blog โ€บ javascript โ€บ quick tip: testing if a string matches a regex in javascript
Quick Tip: Testing if a String Matches a Regex in JavaScript โ€” SitePoint
November 6, 2024 - For example, if you want to find all the digits in a string, you can use the \d special character to represent digits in a regular expression: let str = "The year is 2022."; let result = str.match(/\d+/g); console.log(result); // ["2022"] In ...
๐ŸŒ
Qodex
qodex.ai โ€บ home โ€บ all tools โ€บ getting started โ€บ javascript regex tester
JavaScript Regex Tester โ€” Test Patterns Live Online
Test and debug JavaScript regex patterns in real time. See matches highlighted, capture groups extracted, and flags applied instantly. Free, no signup needed.
Rating: 4.9 โ€‹ - โ€‹ 60 votes
๐ŸŒ
Regex Tester
regextester.com
Regex Tester and Debugger Online - Javascript, PCRE, PHP
Regular Expression Tester with highlighting for Javascript and PCRE. Quickly test and debug your regex.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-the-regextest-method-in-javascript
What is the regex.test() method in JavaScript?
The regex.test() method is used to test for a match in a string. The method returns true if it finds a match; otherwise, it returns false. ... The RegExpObject class deals with regular expressions. Both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on text. ... In the example ...
๐ŸŒ
W3Schools Blog
w3schools.blog โ€บ home โ€บ javascript regex test() method
JavaScript RegEx test() method - W3schools
May 29, 2019 - <!DOCTYPE html> <html> <body> <script> var string = "HELLO WORLD"; var a = new RegExp( "HELLO", "g" ); var print = a.test(string); document.write("Returned value : " + print); </script> </body> </html>
๐ŸŒ
Carmatec
carmatec.com โ€บ home โ€บ guide to mastering javascript regex match with examples
Guide to Mastering JavaScript Regex Match with Examples
December 31, 2025 - Example: <.*?> matches <tag> instead of the entire string. ... Instead of writing a single, massive regex, break tasks into smaller steps or use multiple regexes. ... Always escape special characters when matching them literally (e.g., \. for a dot).
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ String โ€บ match
String.prototype.match() - JavaScript | MDN
The following example demonstrates the use of the global flag and ignore-case flag with match(). All letters A through E and a through e are returned, each its own element in the array. ... const str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; const regexp = /[a-e]/gi; const matches = str.match(regexp); console.log(matches); // ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']