Building our environment

In order to test our Regex patterns, we will build an HTML form, which will process the supplied pattern and match it against a string.

I am going to keep all the code in a single file, so let's start with the head of the HTML document:

<!DOCTYPE html>
<html lang="en">
    <title>Regex Tester</title>
    <link rel="stylesheet" href="">
    <script src=""></script>
        margin-top: 30px;
      .label {
         margin: 0px 3px;


Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have ...

Get JavaScript Regular Expressions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.