# JavaScript Overview – Regular Expressions

The following are examples of regular expressions commonly used in JavaScript.

                var x1 = new RegExp("[a-z].*");

                var x2 = /[a-z].*/;

The test method returns true on a match:

    valid = x1.test(input);

The exec method returns multiple results:

                var x3 = /Tool\d*;
    while (r = x3.exec(text))
    {
      console.log("Found" + r[0] +
        "at" + r.index +
        "now at" + x3.lastIndex);
    }