[OpenSIPS-Users] regular expression matching question

Faheem Muhammad faheem2084 at gmail.com
Fri Jan 5 11:56:11 UTC 2024


Hi Machel,

Appreciate the correction; it was a typo when I posted the question.
However, as Callum mentioned earlier, the "IF" condition with the "=~"
operator doesn't fully support PCRE. It seems that any regular expression
with parentheses isn't matched using the "=~" operator.
Using "pcre_match" or an alternative regular expression would be more
suitable in this case.

Thank you
M. Faheem

On Wed, Jan 3, 2024 at 6:37 PM Michel crans <mcrans at gmail.com> wrote:

>
> 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
>>
> _______________________________________________
> 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/20240105/d72f43da/attachment.html>


More information about the Users mailing list