Problem with strings that contain dashes

I have a shell script that returns a long string, each of which as a phone number as the last substring of the form aaa-ppp-nnnn. I extract the results with the command:

set results_array to (do shell script /usr/local/bin/myscript)'s paragraphs

I have verified the output of ‘myscript’ and it is correct. However, when I display ‘results_array’ everything except the phone number is correct. The phone number is ‘aaappp’. It seems apparent that the dashes are doing something (that is the only substring that contains them) but I don’t know what or how to fix it. Can someone tell me what is going on and how to fix it? TIA.

I think I found where the problem is. It is not what I originally thought. I have to break up the words in the string into a list. I use the following in a repeat:

set wcnt to count of words in (item j of line_array)

Apparently the dashes mean something as a delimiter so my count is wrong. How do I get Applescript to understand that aaa-ppp-nnnn is a single word? TIA.

AppleScript uses ! \ " ( ) ’ : ; ? [ ] { } « » " " ˜ ’ - as word delimiters. The only way around this that I know of is to set a delimiter manually…

words of "call 123-456-7890"
--> {"call", "123", "456", "7890"}

set text item delimiters to space
text items of "call 123-456-7890"
--> {"call", "123-456-7890"}

Thanks but that doesn’t seem to help although it changed the results. At the beginning of my repeat I did:

set default to text item delimiters
set text item delimiters to space

Then after my repeat I did:

set text item delimiters to default

It is still treating it as 3 words. However, when I set a value to words ‘1 thru 3’ it places a space between instead of merging them (i.e. aaa ppp nnnn instead of aaapppnnnn before the added command). It seems like I changed the merging behavior rather then the seperating behavior.

Did you remember to ask for ‘text items’ instead of ‘words’ ? Because AppleScript uses its text item delimiters property for both splitting and combining strings, you could “re=hyphenate” your phone numbers by setting text item delimiters to “-” temporarily.

Thanks. Yep. That’s what I wound up doing.