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
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_regexp_test.asp
JavaScript RegExp test() Method
โฎ Previous JavaScript RegExp ... pattern = /e/; let result = pattern.test(text); Try it Yourself ยป ยท The test() method tests for a match in a string....
๐ŸŒ
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. JavaScript RegExp objects are stateful when they have the global or sticky flags set (e.g., ...
๐ŸŒ
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.
๐ŸŒ
Regex Pal
regexpal.com
Regex Tester - Javascript, PCRE, PHP
Test your Javascript and PCRE regular expressions online.
๐ŸŒ
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 - Regular expressions, also known as regex or regexp, are patterns used to match character combinations in strings. In JavaScript, regular expressions are objects, which can be defined in two ways: using a literal or using the RegExp constructor.
Find elsewhere
๐ŸŒ
Built In
builtin.com โ€บ software-engineering-perspectives โ€บ javascript-regex
A Guide to JavaScript Regular Expressions (RegEx) | Built In
Regex can be created by using forward slashes (/) to enclose the pattern or by using a RegExp constructor. Regex can be tested using the methods RegExp.prototype.test() or RegExp.prototype.exec().
๐ŸŒ
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.demoMatch.regex.value); var m = re.exec(document.demoMatch.subject.value); if (m == null) { alert("No match"); } else { var s = "Match at position " + m.index + ":\n"; for (i = 0; i < m.length; i++) { s = s + m[i] + "\n"; } alert(s); } } function demoReplaceClick() { var re = new RegExp(document.demoMatch.regex.v
๐ŸŒ
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...
๐ŸŒ
Playcode
playcode.io โ€บ regex-tester
Regex Tester Online - Free Regex Validator & Generator
Free online regex tester to test and validate regular expressions with real-time matching. Build, debug, and generate regex patterns instantly. JavaScript regex syntax supported.
๐ŸŒ
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.
๐ŸŒ
RegExr
regexr.com
RegExr: Learn, Build, & Test RegEx
RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp). Supports JavaScript & PHP/PCRE RegEx.
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_regexp.asp
JavaScript Regular Expressions
Regex is a common shorthand for a regular expression. JavaScript RegExp is an Object for handling Regular Expressions.
๐ŸŒ
Eloquent JavaScript
eloquentjavascript.net โ€บ 09_regexp.html
Regular Expressions :: Eloquent JavaScript
let name = "dea+hl[]rd"; let escaped = name.replace(/[\\[.+*?(){|^$]/g, "\\$&"); let regexp = new RegExp("(^|\\s)" + escaped + "($|\\s)", "gi"); let text = "This dea+hl[]rd guy is super annoying."; console.log(regexp.test(text)); // โ†’ true
๐ŸŒ
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.
๐ŸŒ
Mozilla
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Guide โ€บ Regular_expressions
Regular expressions - JavaScript | MDN
Regular expressions are patterns used to match character combinations in strings. In JavaScript, regular expressions are also objects. These patterns are used with the exec() and test() methods of RegExp, and with the match(), matchAll(), replace(), replaceAll(), search(), and split() methods ...
๐ŸŒ
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.