Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

TCL(Tool Command Language) Scripting

string trimleft bug?


Hi,

under Tcl 8.4.14 I tried the following commands:

% string trimleft A1:A2 A1:
2

for a comparison:

% string trimleft a1:A2 a1:
A2.

Is this problem already known?

Regards,
Martin

Martin Mertens schrieb:

> % string trimleft a1:A2 a1:
> A2.

     ^ of course without the dot.

Martin Mertens wrote:
> Hi,

> under Tcl 8.4.14 I tried the following commands:

> % string trimleft A1:A2 A1:
> 2

> for a comparison:

> % string trimleft a1:A2 a1:
> A2.

> Is this problem already known?

What problem are you speaking of? It is behaving as documented, unless
that "." after A2 isn't a typo and you're getting a "." appended where
there is no ".". My guess is, it's a typo.

Are you aware that the documentation for [string trimleft] says it will
trim *any* characters from the *set* of characters given as the last
argument.?

In other words, in the first case it will trim all "A", "1" and ":"
characters (which it did) and in the second it will trim all "a", "1"
and ":" characters, which it did.

--
Bryan Oakley
http://www.tclscripting.com

Bryan Oakley schrieb:

> Are you aware that the documentation for [string trimleft] says it will
> trim *any* characters from the *set* of characters given as the last
> argument.?

Sorry, I wasn't aware that the parameter was treated as a set of single
characters..

Regards,
Martin

At 2007-05-11 10:08AM, "Martin Mertens" wrote:

>  Bryan Oakley schrieb:

> > Are you aware that the documentation for [string trimleft] says it will
> > trim *any* characters from the *set* of characters given as the last
> > argument.?

>  Sorry, I wasn't aware that the parameter was treated as a set of single
>  characters..

To get the behaviour you're looking for:

    % set str A1:A1:A1:A2
    A1:A1:A1:A2
    % set trim A1:
    A1:
    % regsub "^($trim)*" $str "" result
    1
    % set result
    A2

or

    % package require textutil
    0.7
    % set result [lindex [textutil::splitx $str "^$trim"] end]
    A1:A1:A2

--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry

On May 11, 4:08 pm, Martin Mertens <martin-mert@gmx.de> wrote:

> Bryan Oakley schrieb:

> > Are you aware that the documentation for [string trimleft] says it will
> > trim *any* characters from the *set* of characters given as the last
> > argument.?

> Sorry, I wasn't aware that the parameter was treated as a set of single
> characters..

'split' is another command to watch out for that treats a string as a
"list of characters".  I don't like that interface, as it's not very
intuitive, but it's too late to change it now.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc