Re: a re problem

2005-05-28 Thread 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' 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: >

a re problem

2005-05-28 Thread 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 &

Re: a re problem

2005-05-20 Thread cheng
thx for help :) -- http://mail.python.org/mailman/listinfo/python-list

Re: a re problem

2005-05-20 Thread Fredrik Lundh
"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.

Re: a re problem

2005-05-20 Thread Mikael Olofsson
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 --

a re problem

2005-05-20 Thread cheng
>>> 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