Re: a re 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: a re problem

From: James Stroud <jstroud@mbi.ucla.edu>
Date: Sat May 28 2005 - 20:09:28 CEST

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/
Received on Thu Sep 29 16:15:35 2005