This is a little JavaScript Regex tester, just write your Regex as example "\d" or "\w" and a test string like "123abc". It is more like an example as an real use function, but you can see how it works and handle the matches.
Try it:
Matches: Code:
Matches: Code:
<html> <script> function myFunction() { if(document.getElementById("regex").value == ""){ document.getElementById("result").innerHTML = "No Regex";return(0); } var re = RegExp(document.getElementById("regex").value, 'g'); document.getElementById("result").innerHTML = re.execAll(document.getElementById("text").value); } RegExp.prototype.execAll = function(string) { var match = null; var matches = new Array(); while (match = this.exec(string)) { var matchArray = []; for (i in match) { if (parseInt(i) == i) { matchArray.push(match[i]); } } matches.push(matchArray); } return matches; } </script> <body> <textarea id="regex" rows="1" cols="50" onchange="myFunction()" onkeyup="myFunction()" placeholder="Your Regex here..."></textarea> <br> <textarea id="text" rows="4" cols="50"onchange="myFunction()" onkeyup="myFunction()" placeholder="Your Text here..."></textarea> <br> Matches: <div id="result"></div> </body> </html>
Hello! Would you mind if I share your blog with my
twitter group? There’s a lot of folks that I think would really enjoy your content.
Please let me know. Cheers
I visited many sites except the audio quality for audio songs current at this web page is in fact fabulous.
Thanks for finally writing about >JavaScript Regex tester – Paul Scheinast <Liked it!|
Greetings! Very helpful advice in this particular article!
It’s the little changes that produce the biggest changes.
Thanks for sharing!|
I simply want to say I am newbie to blogs and actually savored this blog site. Probably I’m likely to bookmark your website . You absolutely have incredible articles. Kudos for sharing with us your webpage.