[OpenSIPS-Users] regular expression matching question

Michel crans mcrans at gmail.com
Wed Jan 3 14:33:16 UTC 2024


The reason why your second regular expression is not matching the pattern
is because of a typo in the syntax. You have used the ~= operator instead
of the =~ operator, which is the correct way to test if a string matches a
regular expression in PCRE.

Op di 2 jan 2024 om 12:28 schreef Faheem Muhammad <faheem2084 at gmail.com>:

> Hi everyone,
>
> Firstly, I wish you all a Happy New Year with the best wishes for each
> community member and the OpenSIPS project.
>
> I have a question related to regular expressions matching in an IF
> condition.
> There are two identical regular expressions. One RE is matching and one RE
> is not matching the pattern.
>
> *Sample $fU Range:  *+966123456700 to +96612345650
>
> # RE1 - Matching Regular expression
> if($fU =~"\+9661234567[0-4][0-9]|\+966123456750"){
> xlog("re matched\n")
> }
>
> # RE2  - Non matching Regular expression
> if($fU ~="\+9661234567([0-4]\d|50)"){
> } # RE not matched
>
> Can anyone please suggest what I'm doing wrong?
>
> *OpenSIPS version*:     3.2.3
> OS: *Debian 12*
>
>
> Best regards,
> M. Faheem
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20240103/841f0e2b/attachment.html>


More information about the Users mailing list