Answer the question
In order to leave comments, you need to log in
Help with regular Go?
Can you help with the function
/////Функция проверяет номер на валидность
func check_num(client int , id_dispach int) {
/*
Могут поступить номера
+79095876084
79095876084
89095876084
*/
fmt.Println("Проверяю номер на валидность . Номер который поступил в систему ",client)
// проверяю формат номеров
match_kz, _ := regexp.MatchString("^[+0-9]{1}{11,12}$", client) ///регулярка онлайк конструктор https://uiregex.com/ru
match_rus, _ := regexp.MatchString("^[+0-9]{1}{11,12}$", client) ///регулярка онлайк конструктор https://uiregex.com/ru
// как замена множественным if elseif
switch {
case match_kz:
fmt.Println("Номер Казахстан",client,id_dispach)
case match_rus:
fmt.Println("Номер Россия",client,id_dispach)
default: ///если не попал ни под одно условие уйду сюда
fmt.Println("Номер не коректный",client,id_dispach)
return err
}
}
<extension name="out">
<condition field="destination_number" expression="^(?:\+)?(?:[7,8])?72(\d{8})$">
<action application="bridge" data="{leg_timeout=40,ignore_early_media=true}sofia/gateway/goip16/007872$1"/>
</condition>
</extension>
Answer the question
In order to leave comments, you need to log in
Does the specified service find this regular number?"^[+0-9]{1}{11,12}$"
First, you're using the wrong quotes.
This will not work because the backslash inside double quotes is used for escaping. It should be like this:
Secondly, here the regular expression is compiled for each check call, which is very slow, you need to compile it in advance and then use it. For example, like this .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question