On 9/28/2011 5:28 AM, Xah Lee wrote:
curious question.
suppose you have 300 different strings and they need all be replaced
to say "aaa".
is it faster to replace each one sequentially (i.e. replace first
string to aaa, then do the 2nd, 3rd,...)
, or is it faster to use a regex with “or” them al
Willem writes:
> Eli the Bearded wrote:
> ) In comp.lang.perl.misc, Willem wrote:
> )> In Perl, it would be applicable. You see, in Perl, you can call a function
> )> in the replacement of the regex substitution, which can then look up the
> )> html entity and return the wanted unicode literal
Eli the Bearded wrote:
) In comp.lang.perl.misc, Willem wrote:
)> In Perl, it would be applicable. You see, in Perl, you can call a function
)> in the replacement of the regex substitution, which can then look up the
)> html entity and return the wanted unicode literal.
)
) A function? I'd use a
In comp.lang.perl.misc, Willem wrote:
> In Perl, it would be applicable. You see, in Perl, you can call a function
> in the replacement of the regex substitution, which can then look up the
> html entity and return the wanted unicode literal.
A function? I'd use a hash.
> I think you can do th
On Wed, Sep 28, 2011 at 3:28 AM, Xah Lee wrote:
> curious question.
>
> suppose you have 300 different strings and they need all be replaced
> to say "aaa".
>
> is it faster to replace each one sequentially (i.e. replace first
> string to aaa, then do the 2nd, 3rd,...)
> , or is it faster to use a
On 28/09/2011 18:00, Willem wrote:
Xah Lee wrote:
) the question originally came from when i was coding elisp of a
) function that changes html entities to unicode char literal. The
) problem is slightly complicated, involving a few questions about speed
) in emacs. e.g. string vs buffer, and muc
Xah Lee wrote:
) the question originally came from when i was coding elisp of a
) function that changes html entities to unicode char literal. The
) problem is slightly complicated, involving a few questions about speed
) in emacs. e.g. string vs buffer, and much more... i spent several
) hours on
On Wed, Sep 28, 2011 at 11:22 PM, Neil Cerutti wrote:
> I'd like to know what "string replacement" is supposed to mean in
> the context of Python.
>
Substring replacement, such as:
>>> "Hello, world!".replace(", "," -- ")
'Hello -- world!'
The str method doesn't accept a list, though, so it won'
In article <9egld1f38...@mid.individual.net>,
Neil Cerutti wrote:
> On 2011-09-28, Chris Angelico wrote:
> > On Wed, Sep 28, 2011 at 10:28 PM, Xah Lee wrote:
> >> each string needs to be changed to a unique string, not all to
> >> the same string.
> >
> > And you'll find that this is, by and l
On 2011-09-28, Chris Angelico wrote:
> On Wed, Sep 28, 2011 at 10:28 PM, Xah Lee wrote:
>> each string needs to be changed to a unique string, not all to
>> the same string.
>
> And you'll find that this is, by and large, the most normal
> situation. Folding many strings down to one string is a l
On Wed, Sep 28, 2011 at 11:14 PM, Xah Lee wrote:
> (while (< ii (length pairs))
> (setq mystr (replace-regexp-in-string
> (elt tempMapPoints ii)
> (elt (elt pairs ii) 1)
> mystr t t))
> (setq ii (1+ ii))
> )
from __future__ impo
here's more detail about the origin of this problem. Relevant to emacs
lisp only.
--
in the definition of “replace-regexp-in-string”, there's this comment:
;; To avoid excessive consing from multiple matches in long strings,
;; don't just call `replace-match' cont
On Wed, Sep 28, 2011 at 10:28 PM, Xah Lee wrote:
> each string needs to be changed to a unique
> string, not all to the same string.
And you'll find that this is, by and large, the most normal situation.
Folding many strings down to one string is a lot less common. So,
let's have some real-world
On Sep 28, 3:57 am, mer...@stonehenge.com (Randal L. Schwartz) wrote:
> > "Xah" == Xah Lee writes:
>
> Xah> curious question.
> Xah> suppose you have 300 different strings and they need all be replaced
> Xah> to say "aaa".
>
> And then suppose this isn't the *real* question, but one entirely o
> "Xah" == Xah Lee writes:
Xah> curious question.
Xah> suppose you have 300 different strings and they need all be replaced
Xah> to say "aaa".
And then suppose this isn't the *real* question, but one entirely of
Fiction by Xah Lee.
How helpful do you want to be?
--
Randal L. Schwartz - St
On Wed, Sep 28, 2011 at 7:28 PM, Xah Lee wrote:
> suppose you have 300 different strings and they need all be replaced
> to say "aaa".
>
> is it faster to replace each one sequentially
Before you ask "is it faster", you need to first be sure it's correct.
I would recommend doing all the replaces
curious question.
suppose you have 300 different strings and they need all be replaced
to say "aaa".
is it faster to replace each one sequentially (i.e. replace first
string to aaa, then do the 2nd, 3rd,...)
, or is it faster to use a regex with “or” them all and do replace one
shot? (i.e. "1stst
17 matches
Mail list logo