I need to validate a string which will have the format [char][char][num][num][char].
I need to find out if the [char] has anything between AK but not I.
Use a char class and add the two ranges:
[A-HJ-K]
JK
is not really a range and adding the other requirements, try something like:
^[A-HJK]{2}\d{2}[A-HJK]$
^
is an anchor for the start of the string
$
is the anchor for the end of the string
Those anchors are important, otherwise you can match substrings.
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.