[Solved] Regex pattern for following example test test123 [closed]


You can use like ^[a-zA-Z]+[ ][a-zA-Z0-9]+$

function CheckValidation() {
    var str = document.getElementById("txtInput").value;
    var pattern = new RegExp("^[a-zA-Z]+[ ][a-zA-Z0-9]+$");
    var res = pattern.test(str);
    document.getElementById("para").innerHTML = res;
}
<input type="text" id="txtInput" />
<button onclick="CheckValidation()">Check</button>
<p id="para"></p>

solved Regex pattern for following example test test123 [closed]