[Solved] How to write Regex for input values? [closed]


var a="123/4";
var b = 'e123/4';

Variant 1

var regex = new RegExp('^[0-9/]+$');

console.log((a.match(regex)) ? true : false); // true
console.log((b.match(regex)) ? true : false); // false

Variant 2

var regex = /^[0-9/]+$/;

console.log((a.match(regex)) ? true : false); // true
console.log((b.match(regex)) ? true : false); // false

Variant 3

var regex = /^[\d\/]+$/;

console.log((a.match(regex)) ? true : false); // true
console.log((b.match(regex)) ? true : false); // false

4

solved How to write Regex for input values? [closed]