Folks,

I want to allow a string hat either contains a space or not. e.g. "1234AB" or "1234 AB".

my current regex only allows a string with a space, but not when it has no space.

Code:
var input   = "1234 AB";
var string = input.match(/^[1-9]\d{3}\s[A-Z]{2}$/)[0];
document.write(string);