Regular expression testing tool

Just a small tool to check regular expressions in the browser build with JavaScript.

The RegEx tool

Just paste the regular expression and the input string in the provided fields and press the execute button.

Regular expression JavaScript code

The code behind this tool is very simple.

<input type="text" id="regex">
<input type="text" d="input">
<button onclick="executeRegex();">execute</button>
<input type="text" id="match" readonly>
<script>
function executeRegex() {
    var regexInput = document.getElementById("regex").value;
    var input = document.getElementById("input").value;
    var regex = new RegExp(regexInput);
    var match = document.getElementById("match");
    var result = regex.exec(input);
    if (result === null) {
        console.log("No match.");
        match.value = "";
    } else {
        match.value = result[0];
    }
}
</script>
Next Previous