Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return a partion of string

Status
Not open for further replies.

snowingnow

Programmer
Jun 1, 2006
32
CA
Hello, I would like to do this:
That says: if incoming string match this pattern: aaaaa~bbbb~ccccc, i would like to get the partion of ccccc, if not return as null, i am new to tcl, thanks in advance..
(a, b, c string length could be different)
 
It's possible that you're asking either of 2 questions. In the first case, you want to match a pattern and grab the 3rd piece of the match. That would be done with regexp as in
Code:
regexp {(a*~)(b*~)(c*)} <your string> match var1 var2 var3

The simpler question is how to split a string on "~" and find the 3rd part:
Code:
 set var3 [lindex [split <your string> ~] 2]

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top