如何使用正则表达式匹配中间还有空格的八位数字?

Ash*_*sha 1 java regex

我想匹配1234 567812345678

这个正则表达式错了吗?

if(!number.matches("^\\d{4}[, ]\\d{4}$")){
  throw new Exception(" number is not valid : "+number);
}
Run Code Online (Sandbox Code Playgroud)

sbe*_*eam 6

尝试量词之后 []

^\d{4}[\s,]?\d{4}$
Run Code Online (Sandbox Code Playgroud)