problem with re.rearch

Deon Garrett garrett at cs.colostate.edu
Tue Jul 31 01:21:01 EDT 2001


On Tue, 31 Jul 2001 09:03:36 +0800 (CST), sdf <wqh-2 at 263.net> wrote:
> since s=abcd ,then I search 'a' in s
> the result must be true 
> but why the result is nono
> 
>>>> a=re.compile(s)
>>>> b=a.search('a')
>>>> print b
> None
>>>> print s
> abcd

Unless you've lost me somewhere, you're describing something like this:

s = 'abcd'
a = re.compile (s)
b = a.search ('a')

which means, "find a match of the pattern 'abcd' in the string 'a'....
probably not what you mean.  The "None" simply indicates that there is
no instance of 'abcd' in 'a'.  What you want here, is

s = 'a'
pat = re.compile (s)
b = pat.search ('abcd')


> __________________________________________

> DVD´óƬ£¬Ò»ÂÉ10Ôª  http://shopping.263.net/category02.htm
> ÃÀÈÝÑøÑÕ¡¢¼õ·ÊÊÝÉíÃؾ÷  http://shopping.263.net/category10.htm
> 
> 
> 
> 
> 



More information about the Python-list mailing list