I want to find a regex for the following pattern: "AA XXXXXXX"
(two characters, one space and 7 digits).
Example: "AA 1234567"
.
Now I can't find the answer.
The pattern you want is:
[a-zA-Z]{2} [0-9]{7}
exactly two chars (upper or lower case) followed by space followed by exactly 7 digits.
If the characters can only be uppercase like in the sample string:
[A-Z]{2} [0-9]{7}
In Java:
Pattern p = Pattern.compile("[A-Z]{2} [0-9]{7}");
Matcher m = p.matcher("AA 1234567");
boolean b = m.matches();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.