eliminate junk from std.string?

Jonathan M Davis jmdavisProg at gmx.com
Sun Jan 9 16:22:50 PST 2011


On Sunday 09 January 2011 15:19:31 Jimmy Cao wrote:
> I think the tr, replace, and translate functions are a bit awkward.

Really? I use replace() fairly heavily in string-processing code, and I don't 
see anything about it which could be considered awkward.

tr() is definitely cool. I do think that it is a bit awkward if you want to deal 
with the modifiers, but my only real gripe is that I can't replace a character 
with a string of characters (e.g. replace all ":" with " - ") or a string of 
characters with a single character (e.g. replace all " - " with ":"). But I 
don't see a good way to do that. Maybe something with regexes would be better. I 
don't know. But the alternative to tr() in many cases, is multiple calls to 
replace(), which would cause unnecessary heap allocations.

- Jonthaan M Davis


More information about the Digitalmars-d mailing list