简体   繁体   中英

How to to match exact number in regex?

I have this regex /^\+[0-9]{12}$/ , but I want to measure it so that: I must start input with +380, like this: +380 501112233

Also need to have a reex for matching + on start and 12 or less digits How to do that? Thanks is adnvance

This would be the regex that you would be looking for,

^\+380[0-9]{9}$

This regex ensures that you start with +380 . It also ensures that there are 12 digits, inclusive of 380 , after + .

Find the explanation here, https://regex101.com/r/UDjaZV/2/

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