I am trying to write a Regex to match a String having 1st 10 characters capital-alpha numeric and then a space and some other text or a String having 1st 10 alpha numeric charac
You don't need angular brackets for space, try below:
System.out.println("MNA345QWRE ABC".matches("[A-Z0-9]{10}(\\s|$).*")); System.out.println("MNA345QWRE_ABC".matches("[A-Z0-9]{10}(\\s|$)*")); System.out.println("MNA345QWRE".matches("[A-Z0-9]{10}(\\s|$).*"));