Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

fallleaves03

macrumors newbie
Original poster
Sep 23, 2013
2
0
I am writing a script that retrieves text and condenses it into a list separated by commas. I want to condense it more by replacing and switching some specific items of text around.
I want the input of something like
Code:
"suboccipital triangle, vertebral artery, suboccipital nerve, greater occipital nerve, greater occipital artery, ...."
to be
Code:
suboccipital triangle, A: vertebral, N: suboccipital, N: g occipital, A: g occipital,...
I can easily switch "nerve", "artery", "vein", etc to "N:", "A:" etc but they will be on the wrong side of the word(s) to which they refer. Unfortunately, the text is not in a designated order either.

Right now, the only script I have found (and understand) for switching text is:
Code:
set ListAll to (switchText of ListAll from "suboccipital artery" to "A: suboccipital")

to switchText of t from s to r
	set d to text item delimiters
	set text item delimiters to s
	set t to t's text items
	set text item delimiters to r
	tell t to set t to beginning & ({""} & rest)
	set text item delimiters to d
	t
end switchText

but using that would be more tedious than just typing it all out myself and having the beginnings be "N:", "A:" etc is important for what I want to do with the information. Is there a way that I can switch the relevant words around?
Thank you for any insight, ideas or help!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.