Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-09-03
00:54 • Ticket [3563981fff] string trim status still Closed with 5 other changes artifact: 5414c0b2e5 user: dkf
2012-09-01
23:21 • Closed ticket [3563981fff]. artifact: 78b62f1f84 user: nijtmans
15:58 • New ticket [3563981fff]. artifact: be0205098f user: siqsuruq

string trim

Closed / Invalid3563981fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2012-09-01 15:58:19
Strange cuts letter f
example:

set rest fk_frest
string trim $rest fk_

result: rest instead of frest
nijtmansplain2012-09-01 23:21:49
allow_comments - 1

That is as expected. All characters f, k and underscore are stripped from the start of the string
dkfplain2012-09-03 00:54:26
[string trim] (and its trimleft/trimright variants) treats its second (non-operation) argument, if present, as containing a _set_ of characters to remove, not a substring to remove. (If absent, the set is the whitespace characters.) It has always worked this way (for at least 15 years) and it has always been documented to work this way.

I suggest [string map] or [string replace] or [string range] or [regsub] or [regexp]; all can do much more relevant things than [string trim] for the desired transformation.
Log in (anonymous is fine) to add a comment.