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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split with word

Status
Not open for further replies.

mlowe9

Programmer
Apr 3, 2002
221
US
How can I use the split command to split a string by another string, instead of one character?

set newlist [split oldlist MSH|]
set newlist [split oldlist "MSH|"]
set newlist [split oldlist {MSH|}]
set newlist [split oldlist ^(MSH)]

and none have worked. Why is something so easy so hard?
Thanks in advance...
 
Sorry, I didn't explain that very well, and my example sucked too.

I want to split a string by a group of characters. But the command is taking my group of characters and splitting the string by each individually.

Does that make sense?
 
Split only splits on individual characters (AFAIK):
split string ?splitChars?


Returns a list created by splitting string at each character that is in the splitChars argument. Each element of the result list will consist of the characters from string that lie between instances of the characters in splitChars.

To do what you want, I would use:
string first string1 string2 ?startIndex?
and
string range string first last

Bob Rashkin
rrashkin@csc.com
 
Thanks for your response. I will give it a shot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top