Page 1 of 1

Extracting Data From A Tab Delimited String

Posted: Thu Nov 06, 2008 9:36 pm
by warrenk
I have a string that is separated by tabs. Is there any way to extract the data between tabs? I can't use the word command as there are spaces in my data.

example:
tHilitedText Contains...
name <tab> address 1 <tab> address 2

When I try the following, it only selects data up until a space is reached. I want to select until the tab is reached.

put word 1 of tHilitedText into tName
put word 2 of tHilitedText into tAddress1
put word 3 of tHilitedText into tAddress2

Thanks!
Warren

Posted: Thu Nov 06, 2008 10:03 pm
by SparkOut

Code: Select all

set the itemDelimiter to tab
put item 1 of tHilitedText into tName 
put item 2 of tHilitedText into tAddress1 
put item 3 of tHilitedText into tAddress2 
should do the trick

You can "set the itemDelimiter to" very many things, to make your own separators.

Posted: Thu Nov 06, 2008 10:16 pm
by warrenk
SparkOut,

Thanks for helping me out again!!! Appreciate it!

Warren

Posted: Thu Nov 06, 2008 10:23 pm
by SparkOut
No problem.
Just for info, note that the itemDelimiter is a local property and will reset itself to comma at the end of each handler.

Posted: Thu Nov 06, 2008 10:25 pm
by SparkOut
Also here http://support.runrev.com/scriptingconferences/ you will find some useful info, topic 8 and 16 deal with manipulating text.

Posted: Fri Nov 07, 2008 1:44 am
by billworld
Awesome! I was looking to do the same thing today. Thanks!
SparkOut wrote:

Code: Select all

set the itemDelimiter to tab
put item 1 of tHilitedText into tName 
put item 2 of tHilitedText into tAddress1 
put item 3 of tHilitedText into tAddress2 
should do the trick

You can "set the itemDelimiter to" very many things, to make your own separators.