a re problem

Discussion in 'Python' started by cheng, May 28, 2005.

  1. cheng

    cheng Guest

    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?
    cheng, May 28, 2005
    #1
    1. Advertising

  2. cheng

    James Stroud Guest

    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/
    James Stroud, May 28, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Suurkuusk
    Replies:
    0
    Views:
    3,949
    Andreas Suurkuusk
    Jul 27, 2003
  2. Ted Miller
    Replies:
    0
    Views:
    5,135
    Ted Miller
    Sep 13, 2003
  3. Merek
    Replies:
    0
    Views:
    1,942
    Merek
    Dec 3, 2003
  4. Scott Meddows
    Replies:
    1
    Views:
    379
    John Saunders
    Jun 8, 2004
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    528
    Bullschmidt
    May 11, 2004
Loading...

Share This Page