RegExp Tester for JS

by Fernando De Leon

HTML

<button id="b1">
Press
</button>
<input type="text" id="testField" value="07 3395 3398"/>
<input type="textarea" value="\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}" id="regExpStr"/>

JavaScript

$("#b1").on("click",function presser() {
  var regStr = $("#regExpStr").val();
  var re = new RegExp("^"+regStr+"$");
  console.log(re);
  var testFieldVal = $("#testField").val();
  console.log("Do they match! -> "+testFieldVal.match(re)+" on "+testFieldVal);
  
});