- removing chars from string
bruce wrote:
hi...
update. i'm getting back html, and i'm getting strings like foo nbsp;
which is valid HTML as the 'nbsp;' is a space.
, n, b, s, p, ; Those are all ascii characters.
i need a way of stripping/removing the 'nbsp;' from the string
the nbsp
In [EMAIL PROTECTED], bruce wrote:
here is a sample of the text i'm looking to do hte search/replace for...
td valign=top colspan=2 class=sectionheading
bgcolor=#ff ACCT 209 - SURVEY OF ACCT PRIN nbsp;/td
i'm trying to figure out how to replace the nbsp with a
/replace
non-ascii chars...
this would/should resolve my issue..
-bruce
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Simon Forman
Sent: Monday, July 03, 2006 11:28 PM
To: python-list@python.org
Subject: Re: ascii character - removing chars from string
bruce
On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote:
simon...
the issue that i'm seeing is not a result of simply using the
'string.replace' function. it appears that there's something else going on
in the text
although i can see the nbsp in the file, the file is manipulated by a number
.
-bruce
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Steven D'Aprano
Sent: Tuesday, July 04, 2006 8:45 AM
To: python-list@python.org
Subject: RE: ascii character - removing chars from string
On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote:
simon
PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Steven D'Aprano
Sent: Tuesday, July 04, 2006 8:45 AM
To: python-list@python.org
Subject: RE: ascii character - removing chars from string
On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote:
simon...
the issue that i'm seeing is not a result of simply
bruce wrote:
i've done the s.replace('\xa0','') with no luck.
let me guess: you wrote
s.replace(\xa0, )
instead of
s = s.replace(\xa0, )
?
/F
--
http://mail.python.org/mailman/listinfo/python-list
@python.org
Subject: Re: ascii character - removing chars from string
bruce wrote:
i've done the s.replace('\xa0','') with no luck.
let me guess: you wrote
s.replace(\xa0, )
instead of
s = s.replace(\xa0, )
?
/F
--
http://mail.python.org/mailman/listinfo/python-list
--
http
On Tue, 04 Jul 2006 09:01:15 -0700, bruce wrote:
update...
the error i'm getting...
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in
position 62: ordinal not in range(128)
Okay, now we're making progress -- we know what exception you're getting.
Now, how about telling
:[EMAIL PROTECTED] Behalf
Of Steven D'Aprano
Sent: Tuesday, July 04, 2006 9:35 AM
To: python-list@python.org
Subject: RE: ascii character - removing chars from string
On Tue, 04 Jul 2006 09:01:15 -0700, bruce wrote:
update...
the error i'm getting...
UnicodeEncodeError: 'ascii' codec can't
hi...
i'm running into a problem where i'm seeing non-ascii chars in the parsing
i'm doing. in looking through various docs, i can't find functions to
remove/restrict strings to valid ascii chars.
i'm assuming python has something like
valid_str = strip(invalid_str)
where 'strip'
bruce:
valid_str = strip(invalid_str)
where 'strip' removes/strips out the invalid chars...
This isn't short but it is fast:
import string
valid_chars = string.lowercase + string.uppercase + \
string.digits +
|!'\\£$%/()=?^*é§_:;+,.-\n \t
all_chars = .join(map( chr,
On 4/07/2006 9:27 AM, bruce wrote:
hi...
i'm running into a problem where i'm seeing non-ascii chars in the parsing
i'm doing. in looking through various docs, i can't find functions to
remove/restrict strings to valid ascii chars.
It's possible that you would be better off handling those
bruce wrote:
hi...
i'm running into a problem where i'm seeing non-ascii chars in the parsing
i'm doing. in looking through various docs, i can't find functions to
remove/restrict strings to valid ascii chars.
i'm assuming python has something like
valid_str = strip(invalid_str)
where
bruce wrote:
hi...
i'm running into a problem where i'm seeing non-ascii chars in the parsing
i'm doing. in looking through various docs, i can't find functions to
remove/restrict strings to valid ascii chars.
i'm assuming python has something like
valid_str = strip(invalid_str)
where
)
ok_text = foo cat
thanks
-bruce
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Rune Strand
Sent: Monday, July 03, 2006 5:43 PM
To: python-list@python.org
Subject: Re: ascii character - removing chars from string
bruce wrote:
hi...
i'm running into a problem
bruce wrote:
hi...
update. i'm getting back html, and i'm getting strings like foo nbsp;
which is valid HTML as the 'nbsp;' is a space.
, n, b, s, p, ; Those are all ascii characters.
i need a way of stripping/removing the 'nbsp;' from the string
the nbsp; needs to be treated as a
: Monday, July 03, 2006 7:17 PM
To: python-list@python.org
Subject: Re: ascii character - removing chars from string
bruce wrote:
hi...
update. i'm getting back html, and i'm getting strings like foo nbsp;
which is valid HTML as the 'nbsp;' is a space.
, n, b, s, p, ; Those are all ascii
] Behalf
Of Simon Forman
Sent: Monday, July 03, 2006 7:17 PM
To: python-list@python.org
Subject: Re: ascii character - removing chars from string
bruce wrote:
hi...
update. i'm getting back html, and i'm getting strings like foo nbsp;
which is valid HTML as the 'nbsp;' is a space.
, n, b, s, p
19 matches
Mail list logo