Re: ascii character - removing chars from string

2006-07-04 Thread Simon Forman
- 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

RE: ascii character - removing chars from string update

2006-07-04 Thread Marc 'BlackJack' Rintsch
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

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
/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

RE: ascii character - removing chars from string

2006-07-04 Thread Steven D'Aprano
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

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
. -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

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
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

Re: ascii character - removing chars from string

2006-07-04 Thread Fredrik Lundh
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

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
@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

RE: ascii character - removing chars from string

2006-07-04 Thread Steven D'Aprano
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

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
:[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

ascii character - removing chars from string

2006-07-03 Thread bruce
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'

Re: ascii character - removing chars from string

2006-07-03 Thread bearophileHUGS
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,

Re: ascii character - removing chars from string

2006-07-03 Thread John Machin
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

Re: ascii character - removing chars from string

2006-07-03 Thread Rune Strand
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

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
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

RE: ascii character - removing chars from string

2006-07-03 Thread bruce
) 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

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
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

RE: ascii character - removing chars from string

2006-07-03 Thread bruce
: 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

RE: ascii character - removing chars from string update

2006-07-03 Thread bruce
] 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