RegExp match test

Developer
Size
2,165 Kb
Views
46,552

How do I make an regexp match test?

What is a regexp match test? How do you make a regexp match test? This script and codes were developed by Honglio on 11 August 2022, Thursday.

RegExp match test Previews

RegExp match test - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>RegExp match test</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <title>RegExp - search for strings</title>
<form id="textsearch">
<textarea id="incoming" cols="150" rows="8">
/** * @license Handlebars hbs 0.8.1 - Alex Sexton, but Handlebars has its own licensing junk * * Available via the MIT or new BSD license. * see: http://github.com/jrburke/require-cs for details on the plugin this was based off of */
</textarea>
<p> Search pattern: <input id="pattern" type="text" value="bu(t|r)"/>
</p>
</form>
<p id="searchSubmit">Search for pattern</p>
<div id="searchResult"></div> <script src="js/index.js"></script>
</body>
</html>

RegExp match test - Script Codes CSS Codes

#searchSubmit { background-color: #ff0; width: 200px; text-align: center; padding: 10px; border: 2px inset #ccc;
}
.found { background-color: #ff0;
}

RegExp match test - Script Codes JS Codes

window.onload = function () { document.getElementById("searchSubmit").onclick = doSearch;
};
function doSearch () { var pattern = document.getElementById("pattern").value; var re = new RegExp(pattern, "g"); var searchString = document.getElementById("incoming").value; var matchArray; var resultString = "<pre>"; var first = 0; var last = 0; while((matchArray = re.exec(searchString)) != null) { last = matchArray.index; resultString += searchString.substring(first, last); resultString += "<span class='found'>" + matchArray[0] + "</span>"; first = re.lastIndex; } resultString += searchString.substring(first, searchString.length); resultString += "</pre>"; document.getElementById("searchResult").innerHTML = resultString;
}
RegExp match test - Script Codes
RegExp match test - Script Codes
Home Page Home
Developer Honglio
Username honglio
Uploaded August 11, 2022
Rating 3
Size 2,165 Kb
Views 46,552
Do you need developer help for RegExp match test?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Honglio (honglio) Script Codes
Create amazing Facebook ads with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!