Fredrik Lundh schreef:
> John Machin wrote:
>
>>> $ python2.4 -mtimeit -s "str = 'D c a V e r \" = d w o r d : 0 0 0 0 0 6
>>> 4 0'" 'str.replace(" ", "")'
>> Oi! The OP mentioned "whitespace" ...
>
> yeah. but as is obvious from his examples, he really means "UTF-16", not
> whitespace.
Yes, tha
John Machin wrote:
> > $ python2.4 -mtimeit -s "str = 'D c a V e r \" = d w o r d : 0 0 0 0 0 6
> > 4 0'" 'str.replace(" ", "")'
>
> Oi! The OP mentioned "whitespace" ...
yeah. but as is obvious from his examples, he really means "UTF-16", not
whitespace.
--
http://mail.python.org/mailman/l
On 14/04/2006 12:51 PM, Felipe Almeida Lessa wrote:
> Em Sex, 2006-04-14 às 12:46 +1000, Steven D'Aprano escreveu:
>> Why would you want to call in the heavy sledgehammer of regular
>> expressions for cracking this peanut?
>
> And put heavy on that!
>
> $ python2.4 -mtimeit -s "str = 'D c a V e r
On 13 Apr 2006 12:32:56 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> re.sub() doesn't do the substitution in place: it returns the resulting
> string. Try this:
In-place substitution is impossible in Python, strings are immutable.
--
http://mail.python.org/mailman/listinfo/python-list
Em Sex, 2006-04-14 às 12:46 +1000, Steven D'Aprano escreveu:
> Why would you want to call in the heavy sledgehammer of regular
> expressions for cracking this peanut?
And put heavy on that!
$ python2.4 -mtimeit -s "str = 'D c a V e r \" = d w o r d : 0 0 0 0 0 6
4 0'" 'str.replace(" ", "")'
1
On Thu, 13 Apr 2006 12:09:32 -0700, Kelvie Wong wrote:
> try this:
>
> string = 'D c a V e r " = d w o r d : 0 0 0 0 0 6 4 0'
> import re
> re.sub("\s", "", string)
Why would you want to call in the heavy sledgehammer of regular
expressions for cracking this peanut?
old_s = 'D c a V e r " = d w
On Apr 13, 2006, at 12:09 PM, Kelvie Wong wrote:
> try this:
>
> string = 'D c a V e r " = d w o r d : 0 0 0 0 0 6 4 0'
> import re
> re.sub("\s", "", string)
>
> On 4/13/06, david brochu jr <[EMAIL PROTECTED]> wrote:
>
Even easier (if you only want to replace blank spaces, and not all
whitespa
re.sub() doesn't do the substitution in place: it returns the resulting
string. Try this:
myString = 'D c a V e r " = d w o r d : 0 0 0 0 0 6 4 0'
import re
newString = re.sub("\s", "", myString)
print newString
--
http://mail.python.org/mailman/listinfo/python-list
try this:
string = 'D c a V e r " = d w o r d : 0 0 0 0 0 6 4 0'
import re
re.sub("\s", "", string)
On 4/13/06, david brochu jr <[EMAIL PROTECTED]> wrote:
>
> Hi again,
>
> Trying to remove whitespace from a string in a text file.
>
> the string is:
> D c a V e r " = d w o r d : 0 0 0 0 0 6 4 0
>