Re: string handle problem



In article <1133236687.367401.235180@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
slebetman@xxxxxxxxx <slebetman@xxxxxxxxx> wrote:
>MH wrote:
>> In article <1133231209.671223.49750@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
>> Hans <hansyin@xxxxxxxxx> wrote:
>> >Hi, I encountered a string handle problem and need help.
>> >In my code, I have a string which value could be "a1/a2" or "a2/a3/a4"
>> >or "a2/b3/c3/a5", now I hope to get the last sub_string after "/", for
>> >"a1/a2", I need "a2", for "a2/a3/a4" , I need "a4", and for
>> >"a2/b3/c3/a5", I need a5.
>> >
>> >I knew I can use split command and then handle the list to get the last
>> >one, but it seems a little complex, Is there an easy way to get it?
>> >I'm thinking to use regexp, but regexp handle string in order from left
>> >to right by default, I don't know how to change it to 'from right to
>> >left'.
>> >
>> >Thanks a lot.
>>
>>
>> What platform are you on? This MIGHT be doable using the [file tail]
>> command, or some other variant of file..
>>
>
>I think it should work regardless of platform. Remember that Tcl
>normalises file paths to slashes on all platforms.

Ok, guess I misread the documentation.. I thought file used whatever
separator was appropriate for the platform, and that based on the note at
the end of "file join", "/" was for unix (forgot "/" was for win), and ":"
was used for Mac.

I guess that was my mistake in reading it - I suppose it means that / is
"root" for unix and win, and ":" is root for Mac, and "/" is used as path
separator everywhere?

MH
.



Relevant Pages

  • Re: string handle problem
    ... I encountered a string handle problem and need help. ... >>I knew I can use split command and then handle the list to get the last ... >>I'm thinking to use regexp, but regexp handle string in order from left ... I think it should work regardless of platform. ...
    (comp.lang.tcl)
  • Re: string handle problem
    ... I encountered a string handle problem and need help. ... >I knew I can use split command and then handle the list to get the last ... >I'm thinking to use regexp, but regexp handle string in order from left ... This MIGHT be doable using the [file tail] ...
    (comp.lang.tcl)
  • Re: string handle problem
    ... Hans wrote: ... I knew I can use split command and then handle the list to get the last ... I'm thinking to use regexp, but regexp handle string in order from left ... You can also use 'string last' to find the last occurance of "/", then grab all the chars after that with 'string range' ...
    (comp.lang.tcl)
  • RE: IE headers w patch level - new info
    ... Internet Settings\User Agent\Post Platform ... String Value: Q312461 ... The patch information that Internet Explorer displays ... logfiles, under the UserAgent field. ...
    (Focus-Microsoft)
  • Re: some interesting perspectives on .NET from the other camp ...
    ... >> now rather use framework functionality directly. ... Do you really think a VB.NET writer is any more dependent on MS ... low platform or framework level functions altogether. ... Trimming a string just seems to me to be exactly ...
    (borland.public.delphi.non-technical)