by
97 7
0
3
143
1
Popular
Specified
OpenSource
Created
Modified Aug 20, 2017
No tags for this snippet yet.
Languagecsharp
Languagejavascript

Check whether a string matches a regex

Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/2519029/Check-whether-a-string-matches-a-regex?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
//RegExp allows to inject variable values into the regex string var str = "sample1"; var re = new RegExp("^([a-z0-9]{5,})$"); if (re.test(str)) { console.log("valid"); } else { console.log("invalid"); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus