Q:

Using regular expressions in JAVA how do i say 4 any letter a space and then 4 numbers

What I want is a class code like ACCT 4838. 
I tried
String REGEX = "[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][\\s][\\d][\\d][\\d][\\d]";
String REGEX = "[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z]\\s\\d\\d\\d\\d"

I apologize if this gets flagged i have been looking around for a while and i cant quite peg what it is im doing wrong. should be a quick one for someone.

A:

You can use a regex like this:
(?i)^[a-z]{4} \d{4}$   // With inline insensitive flag
^[A-Za-z]{4} \d{4}$    // without inline flag

Remember to escape backslashes in java like ^[A-Za-z]{4} \\d{4}$
IdeOne example

