sanket patil
sanket patil

Reputation: 13

How to get the entire string from from particular index in TCL

I want 10576.53012.46344.35174 from string

"CompositionClassification|CC000003|01|10576.53012.46344.35174"

I have index of last occurrence of |, how will i get complete 10576.53012.46344.35174 sub-string from last |

Not familiar with TCL, Suggest solution on this :)

Upvotes: 1

Views: 558

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137567

If you know the index of the first character you want, and you want from there to the end, you use:

set theSubstring [string range $theString $idx end]

However in this case I'd use split and lindex, since it looks like a simple delimited list:

set theSubstring [lindex [split $theString "|"] end]

Upvotes: 1

Related Questions