a re problem

James Stroud jstroud at mbi.ucla.edu
Sat May 28 14:09:28 EDT 2005


py> import re
py> target = 'blah'
py> text = 'yaddah blah yaddah yaddah'
py> ext = re.sub(r'\b%s\b' % target,'',text)
py> ext
'yaddah  yaddah yaddah'


On Friday 27 May 2005 10:56 pm, cheng wrote:
> hi,all, i try to replace every target word found in the text
>
>  for target in splitText:
>         if stopwords.find(target) >= 0 :
>             text = re.sub(r'\b%s\b','',text) &target
>
> when i using the statment:
>
> text = re.sub(r'\b%s\b','',text) &target
>
>  get error : unsupported operand type(s) for &: 'str' and 'str'
>
> is it some idea that can modity it and make it work?

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/



More information about the Python-list mailing list