[SR-Users] Regex module having trouble with large regex expressions in kamailio 4.4.5

Tim Balmer t.balmer at edutel.nl
Thu Mar 23 09:05:34 CET 2017


I discovered some strange behavior from the regex module yesterday (kamailio version 4.4.5). 

For example we have the phone number 0033755500381 that we try to match with the following kamailio code:

	if (pcre_match_group("$rU", REGEX_FF_NEG_INTERNATIONAL))
		# Do something

When the content of our regex groups file is like this:

	^(\+|00)3(0690|0693|0694|0695|0697|0698|0699|36|37|4160|46|47|51160|511691|511693|511696|511891|511893|511896|513|516091|5160921|516093|516096|516391|516392|516393|516396|516591|516592|516593|516596|516691|5166921|516693|516696|5191|5192|5193|5196|538|54388|543	89|546|5475|5477|548|567117|5672|5677|5679|5692|5694|5696|5698|5699|5795|5796|5797|5799|58299|584|5850|5948|5987|5988|5989|59988|59989|620|630|631|670|706|712|725|728|774|776|8591|8592|8595|8597|8598|8599|8620|8621|8630|8631|8640|8641|8643|8649|8650|8651|8660|	8661|8664|8670|8671|869814|906698|93)

The above if statment is not matching, although it should match according to any regex validator (for example https://regex101.com/ )

But when I split the above regex in smaller parts, like this:


Then the exact same regex module call as before does result in a match as expected.

So to me it looks like the regex module is having trouble with large regex expressions, I did check the logs but there is nothing strange there, that means also the large expression is correctly loaded according to the logs while in fact it is not working. Checked the regex module documentation but there I cannot find any limits regarding to the size of invididual expressions. 

Is it me missing something or did I discover a bug in de regex module?

Best Regards,

Tim Balmer
Edutel BV

More information about the sr-users mailing list