a re problem

C

cheng

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?
 
J

James Stroud

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'


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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top