JSFiddle - React, Tailwind, and code Playground

by jfriend00

CSS

body {font-family: "Courier New";}

JavaScript

var testValues = [
    "+91-9198370583",
    "9198387083",
    "09198387083",
    "+919198387083",
    "91983870832",
    "+91919+8387083"
];

var re = /^(\+91-|\+91|0)?\d{10}$/;
var result;

for (var i = 0; i < testValues.length; i++) {
    result = testValues[i] + " ";
    if (testValues[i].match(re)) {
        result +=  "matched";
    } else {
        result += "did not match";
    }
    $(document.body).append(result + "<br>");
}