In 1st regex, the string is getting split considering last / sign.
In 2nd regex, the string is getting split considering first / sign.
So basically whatever is there before the first & last / is getting omitted. I hope you understood.
Thanks bipinajith for helping..
There are slight differences between perl and tcl's regex function in this case. Nevertheless, thanks to your sharing, I think I've figured out the meaning of this tcl's regex function code:
regexp {(\S+)\/[^\/]+$} $String match GetString
Here's what I figured out:
The first bracket (\S+), means to search for characters or numbers or symbols except whitespaces (spacebar or tab). This means that at this phase, the searched pattern is abc/def/gh.
The next phase \/[^\/]+$ is to search for the last / plus one or more characters or numbers or symbols except the / symbol till the end of the string. Only the matched pattern inside the ( ) will be copied to GetString which means in this case abc/def
This is what I found out, please comment if I'm wrong.