Your examples did not follow your question. Look like your valid mobile number consists of 10 digits with or without 2 single spaces in between. Right, the try the sample code:
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Validate...</button>
<script>
function myFunction() {
var result = "Failed!";
var isMatched = false;
// First validate the pattern, ignoring digits count
var mobileNum = "0211 234 567";
var pattern = /^\d+\s?\d+\s?\d+$/g;
var isMatched = pattern.test(mobileNum );
// Next do digits count
if (isMatched){
var digits = mobileNum.replace(/ +/g, "");
if(digits.length == 10){
result = "Passed!";
}
}
alert(result);
}
</script>
</body>
</html>