Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[string replace] refuses to replace empty substrings

Open3608714fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 12 years ago
Descriptionplain2013-03-21 14:11:51
Can't believe I missed this.  Should have been part
of the Do Nothing Gracefully cleanup.

You cannot use [string replace] to insert a substring
without at the same time taking at least on character
out.

% string replace abcde 1 0 h
abcde

Instead of the result any sane programmer would
expect:

ahbcde

In particular, the useful case of prepending is not
supported.

Recategorize to a Feature Request if you must.  (This
misfeature is documented, FFS).  But it's so boneheaded
it looks like a bug to me.
dgpplain2013-04-10 21:18:06
See branch bug-3608714.

Surprising thing is that the test suite does not care.
dgpplain2015-02-18 20:45:35
See also:

https://sourceforge.net/p/tcl/mailman/message/20466029/
dkfhtml2015-02-18 21:49:17

Bug-by-design? Meh. While I think this is something that will need flagging up as a change when it gets done, it can probably go on the 8.6 track as who in their right mind would be relying on the current behaviour?

dgpplain2015-02-18 21:58:00
I no longer recall, but whatever it was, it was enough
to suspend the feature change at the time.

I'd start looking with tcllib.
dkf Ticket [3608714fff]: 3 changes [History diff]2015-05-18 07:55:38
dgpplain2015-05-18 14:41:33
bug-3608714 branch updated.
Log in (anonymous is fine) to add a comment.