Re: regular expression problem
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: regular expression problem

From: alex23 <wuwei23@gmail.com>
Date: Tue May 31 2005 - 10:54:33 CEST

borges2003xx@yahoo.it wrote:
> hi everyone
> there is a way, using re, to test (for es) in
> a=[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14] if a list b is
> composed by three "sublists" of a separated or not by elements.

Heya,

Is there any particular reason why you need to use re?

If you're using Python 2.3 or greater, the sets module might be easier
to deal with here:

>>> from sets import Set
>>> a = Set([1,2,3,4,5,6,7,8,9,10,11,12,13,14])
>>> b = Set([2,3,4,7,8,12,13])
>>> b.issubset(a)
True
>>> b = Set([1,2,5,14])
>>> b.issubset(a)
True
>>> b = Set([3,7,23,200])
>>> b.issubset(a)
False

Sets are unsorted, I'm uncertain if that's a requirement for you.

Hope this helps.
-alex23
Received on Thu Sep 29 16:17:01 2005