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

Help with Parsing a string 1

Status
Not open for further replies.

Ati2ude

Programmer
Dec 11, 2001
79
US
I have been tasked with determing if a given string contains a @ character. If so remove the character and concat the remaining values together to form a new string. I am leaning towards something like this.


regsub -all "\-" $oldstring "" newstring

Is this the best method for handling this?? Thanks in advance for the advice.

Ati2ude
 
I'd use "string map {@ ""} <your string>". It's a little faster than regsub.

Bob Rashkin
rrashkin@csc.com
 
Would this work if I had multiple "@" characters in the string? In reviewing my documentation I have not found the string map function and am not familiar with it. Thanks again for the response, BTW I did some testing with the function and it works great!

Ati2ude
 
Yes. "string map {@ ""} ..." will change all instances of "@".

Bob Rashkin
rrashkin@csc.com
 
Bong that worked like a champ. SOrry have not had time to thank you for the POST, we are finally getting some breathing room.

Ati2ude
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top