简体   繁体   中英

Regular Expression search to search exact match

I am very much new to regex.

I have a scenario where I need to check the textbox value to the below format:

Format: AZnnnnnnn-nnn

The value has to start with "AZ" followed by 7 numerics and -(hiphen) and followed by 3 numerics

Can someone help on this

You can use this regex:

^AZ\d{7}-\d{3}$

^       -> start of string
AZ      -> AZ
\d      -> digit
{7}     -> exactly 7
-       -> hyphen
{3}     -> exactly 3
$       -> end of string

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM