[OpenSIPS-Users] creating a regular expression

mayamatakeshi mayamatakeshi at gmail.com
Mon Oct 10 14:40:45 CEST 2011


On Mon, Oct 10, 2011 at 9:20 PM, Toyima Dias <toyimads at gmail.com> wrote:

> sorry, the range is 31297 - 31336...
>
> 2011/10/10 Toyima Dias <toyimads at gmail.com>
>
>> Hello,
>>
>> i would like some help on a regular expression using dialplan module and
>> regular expressions...this is what i want:
>>
>> construct a regular expression for the following range: 31297-313336...i
>> heve this simple string ^31[2-3]....the problem is the range from 97 to
>> 36...any help please?
>>
>
I don't know if there is a simpler way.
Here' it what i would use:

^(3129[789]|313([0-2][0-9]|3[0-6]))$

Test with this:

#!/usr/bin/python
import re
r = re.compile("^(3129[789]|313([0-2][0-9]|3[0-6]))$")
count = 0
for i in range(100000):
        if r.match(str(i)):
                count = count + 1
print "Expected: " + str(31336 - 31296)
print "Result:   " + str(count)

regards,
Takeshi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20111010/4bcf91b0/attachment.htm>


More information about the Users mailing list