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

Extracting tabs from a text string

Status
Not open for further replies.

Withnail73

Programmer
Nov 16, 2008
2
GB
Hi there! This must be a simple one but I can't seem to manage it. I'm reading a text file in line by line - the file was originally an xls spreadsheet that has been saved as txt and the columns tab delimited. If my collected string is "123456 " where the whitespace is a tab, how do I remove it? STRIP isn't working...
 
Hi Withnail73,

This code:
Code:
/* define TAB in HEX */
tab='09'X
/* Construct string with trailing tabs */
mystring = "123456"||tab||tab
say "mystring with trailing tabs    = '"||mystring||"'"

/* Strip Trailing Tabs from string*/
mystring=strip(mystring,T,tab)
say "mystring without trailing tabs = '"||mystring||"'"

results in:
Code:
mystring with trailing tabs    = '123456                '
mystring without trailing tabs = '123456'
It seems to do what you need.
 
Bingo!! Thanks, mikrom - I was pulling my hair out.
happy.gif
 

If you have to parse text on both sides:
Code:
tab = '09'x
parse var inputstring fld1 (tab) fld2 (tab) fld3 ...etc

Frank Clarke
--Is it time for another Boston Tea Party?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top