create regex for string in js code example
Example 1: using regex in javascript
//Adding '/' around regex
var regex = /\s/g;
//or using RegExp
var regex = new RegExp("\s", "g");
Example 2: generate string from regex javascript
console.log(new RandExp(/^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}$/).gen());
console.log(new RandExp(/^[0-9]{4}$/).gen());
console.log(new RandExp(/^[0-9,A-Z]{4}$/).gen());
console.log(new RandExp(/^([A-Z]){5}([0-9]){4}([A-Z]){1}$/).gen());