Regex trouble

2009-09-24 Thread Support Desk
I am trying to loop over a dictionary of phone numbers and using a python regex to determine if they are long distance or local and then adding them to their appropriate dictionary, My regex doesn't appear to be working though. My regex's are these international__iregex=r'^1?(011|001)'

Regex trouble

2009-09-24 Thread Support Desk
I am trying to loop over a dictionary of phone numbers and using a python regex to determine if they are long distance or local and then adding them to their appropriate dictionary, My regex doesn't appear to be working though. My regex's are these international__iregex=r'^1?(011|001)'

Re: Regex trouble

2009-09-24 Thread MRAB
Support Desk wrote: I am trying to loop over a dictionary of phone numbers and using a python regex to determine if they are long distance or local and then adding them to their appropriate dictionary, My regex doesn't appear to be working though. My regex's are these

Re: Regex trouble

2009-09-24 Thread Simon Forman
On Thu, Sep 24, 2009 at 10:43 AM, Support Desk m...@ipglobal.net wrote: I am trying to loop over a dictionary  of phone numbers and using a python regex to determine if they are long distance or local and then adding them to their appropriate dictionary, My regex doesn't appear to be working

Re: Regex trouble

2009-09-24 Thread Rhodri James
On Thu, 24 Sep 2009 19:45:37 +0100, Simon Forman sajmik...@gmail.com wrote: FWIW this problem is too simple (IMHO) for regular expressions. Simply carve off the first three digits and check against sets of the prefixes you're interested in: #any number starting with these prefixes is not

Re: Regex trouble

2009-09-24 Thread Simon Forman
On Thu, Sep 24, 2009 at 6:31 PM, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 24 Sep 2009 19:45:37 +0100, Simon Forman sajmik...@gmail.com wrote: FWIW this problem is too simple (IMHO) for regular expressions. Simply carve off the first three digits and check against sets of the

Re: Regex trouble

2009-04-02 Thread akshat agarwal
Thanks Andrew. I was also of the same view that perl handled this via some special cases. On Wed, Apr 1, 2009 at 8:32 PM, andrew cooke and...@acooke.org wrote: more exactly, my guess is perl has a special case for this that avoids doing a search over all possible matchers via the pushdown

Regex trouble

2009-04-01 Thread akshat agarwal
Hi, I am trying to use the following snippet of code to print a regex match. s = '01234567890123456789x012' pat = r'(.*?x|[^a]+)*y' mo = re.search(pat, s) if mo is not None: print mo.group(0) By adding one character before the 'x' in the input string, the time taken to print the match

Re: Regex trouble

2009-04-01 Thread andrew cooke
.*? is a not greedy match, which is significantly more difficult to handle than a normal .*. so the performance will depend on quite complex details of how the regular expression engine is implemented. it wouldn't surprise me if perl was better here, because it comes from a background with a

Re: Regex trouble

2009-04-01 Thread andrew cooke
more exactly, my guess is perl has a special case for this that avoids doing a search over all possible matchers via the pushdown stack. andrew cooke wrote: .*? is a not greedy match, which is significantly more difficult to handle than a normal .*. so the performance will depend on quite