[EMAIL PROTECTED] wrote:
> hi everyone.
> a problem:
> two binary strings, a="0101" b="000011110100";
> i search a function f(a,b) that gives 1 if a is "contained" in b with
> any sub strings interposed.
> in this example a in contained cause 000<01>111<01>00 but also
> 0<0>001111<101>00"
>  but also <0>0001111<101>00 but also 000<0>1111<01>0<0> etc....
> any idea?
> Thanx in advance.
> Giorgi Borghi

You can do this easily with regular expressions though I guess may be poor with 
long strings:
  >>> import re
  >>> re.search('0.*1.*0.*1', '000011110100')
<_sre.SRE_Match object at 0x008D9BF0>
  >>> _.span()
(0, 10)
Put the chars of the search string in groups if you need to know where they 
were found.

Kent
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to