string handle problem



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.

.



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 ... 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: String#to_rx ?
    ... I disagree that either #to_re or #to_rx would be a good name for this ... I think that it would be better to have a method on Regexp ... If it's to be on String, though, it should probably be on a few others ... Prev by Date: ...
    (comp.lang.ruby)