regex help

Cédric Lucantis omer at no-log.org
Mon Jun 30 11:16:47 EDT 2008


Le Monday 30 June 2008 16:53:54 Support Desk, vous avez écrit :
> Hello,
>    I am working on a web-app, that querys long distance numbers from a
> database of call logs. I am trying to put together a regex that matches any
> number that does not start with the following. Basically any number that
> does'nt start with:
>
>
>
> 281
>
> 713
>
> 832
>
>
>
> or
>
>
>
> 1281
>
> 1713
>
> 1832
>
>
>
>
>
> is long distance any, help would be appreciated.

sounds like str.startswith() is enough for your needs:

if not number.startswith(('281', '713', '832', ...)) :
	...

-- 
Cédric Lucantis



More information about the Python-list mailing list