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
The test() method of RegExp instances executes a search with this regular expression for a match between a regular expression and a specified string. Returns true if there is a match; false otherwise.
๐ŸŒ
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.
Discussions

Check whether a string matches a regex in JS
I wouldn't rely on this behavior. It depends on your environment's implementation of test(). (match fails because numbers don't have a match member). I'd reccomend explicitly converting your number to a string if you want to use it with a regex (String(123) for example). More on stackoverflow.com
๐ŸŒ stackoverflow.com
Extract Matches VS Test
Tell us whatโ€™s happening: Iโ€™m curious why when you use test() method, you use the the method as regex.test(str) let regex = /Code/; let result = regex.test(str); When you use match() method, you use the method as str.match(regex) let regex= /Code/; let result = str.match(regex); The only ... More on forum.freecodecamp.org
๐ŸŒ forum.freecodecamp.org
1
0
July 6, 2019
Regular Expressions test() - match()? Are these used interchangeably?
Jonathan Grieve is having issues with: Just a quick question to help clear up some confusion. Joel mentions the match() method but seems to use the test() method in its place.... More on teamtreehouse.com
๐ŸŒ teamtreehouse.com
1
September 4, 2017
RegEx test method (Javascript)
Whelp, this is not a regex problem, but a Javascript problem. What's happening here is that when you're using the g flag, the regex pattern is "stateful", meaning that it remembers where it left off in the expression when it starts testing another expression. The docs say ... JavaScript RegExp objects are stateful when they have the global or sticky flags set (e.g. /foo/g or /foo/y). They store a lastIndex from the previous match. To fix this, you can either reset the lastIndex or do not use the g flag. Here is a great article that explains it way better than I could More on reddit.com
๐ŸŒ r/regex
2
1
July 30, 2021
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_regexp_test.asp
W3Schools.com
cssText getPropertyPriority() getPropertyValue() item() length parentRule removeProperty() setProperty() JS Conversion ยท โฎ Previous JavaScript 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 ยป ยท
๐ŸŒ
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.
๐ŸŒ
Softchris
softchris.github.io โ€บ pages โ€บ javascript-regex.html
Regex in JS - how YOU can learn it and learn to like it
Or like this where we create an ... for a match in a string. It returns an array of information or null on a mismatch. test(), tests for a match in string, answers with true or false...
Find elsewhere
๐ŸŒ
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.
๐ŸŒ
Mozilla
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Guide โ€บ Regular_expressions
Regular expressions - JavaScript | MDN
An online tool to learn, build, & test Regular Expressions. ... An online interactive tutorials, Cheat sheet, & Playground. ... An online visual regex tester.
๐ŸŒ
Honeybadger
honeybadger.io โ€บ blog โ€บ javascript-regular-expressions
The ultimate JavaScript regex guide - Honeybadger Developer Blog
May 9, 2025 - Note: You don't need to add forward slashes to the pattern when using the RegExp constructor to create patterns, but you do need to enclose them in either single or double quotes. There are different ways to test regex patterns in JavaScript, depending on how you want the result returned.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ RegExp
RegExp - JavaScript | MDN
A string that contains the flags of the RegExp object. ... Whether to test the regular expression against all possible matches in a string, or only against the first.
๐ŸŒ
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("GEEK",); let rex = regex.test(str); console.log(rex);
๐ŸŒ
Debuggex
debuggex.com
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.
Test your regex by visualizing it with a live editor. JavaScript, Python, and PCRE.
๐ŸŒ
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
๐ŸŒ
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 - In this quick JavaScript regex matching guide, you'll learn how to test if a string matches a regular expression using the test() method.
๐ŸŒ
Trackingplan
trackingplan.com โ€บ regex-tester
Regex Tester Online: Test & Validate Regular Expressions | Trackingplan
Test and validate your regular expressions with our Online Regex Tester. Supports JavaScript, TypeScript, and more. Try our Regex Checker and Validator.
๐ŸŒ
Regex Pal
regexpal.com
Regex Tester - Javascript, PCRE, PHP
Test your Javascript and PCRE regular expressions online.