简体   繁体   中英

Asterisk Dialplan Phone exten to RegEx

Need to build a RegEx, that came from asterisk dialplan (Brazil Number)

valid      = 0021987126408
not valid  = 002198712640
not valid  = 3021987126408
valid      = 0021987126408

need to validate asterisk with dialplan => 00ZX[789]XXXXXXXXX

check in order .....

  • check if the two first numbers is ZERO

  • check ZX (brazilian DD)

  • check (7,8 or 9)

  • check if XXXXXXXXX has the same quantity of numbers in the end

basicly transcribe asterisk Dialplan to Normal REGEX.

RegEx = ^(00\\d{2}[7-9]\\d{8})$

valid      = 0021987126408
not valid  = 002198712640
not valid  = 3021987126408
valid      = 0021987126408

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