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:
>
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 &
thx for help :)
--
http://mail.python.org/mailman/listinfo/python-list
"cheng" <[EMAIL PROTECTED]> wrote:
> >>> p.sub('','a\nbc')
> 'abc'
> >>> p.sub('','%s') % "a\nbc"
> 'a\nbc'
>
> is it anyone got some idea why it happen?
>>> p.sub('', 'a\nbc')
Traceback (most recent call last):
File "", line 1, in ?
NameError: name 'p' is not defined
>>> import re
>>> p = re.
cheng wrote:
>>>p.sub('','%s') % "a\nbc"
>>>
>>>
>'a\nbc'
>
>is it anyone got some idea why it happen?
>
Make that
p.sub('','%s' % "a\nbc")
Regards
/Mikael Olofsson
Universitetslektor (Senior Lecturer [BrE], Associate Professor [AmE])
Linköpings universitet
--
>>> p.sub('','a\nbc')
'abc'
>>> p.sub('','%s') % "a\nbc"
'a\nbc'
is it anyone got some idea why it happen?
--
http://mail.python.org/mailman/listinfo/python-list