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
to be
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:
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!
I want the input of something like
Code:
"suboccipital triangle, vertebral artery, suboccipital nerve, greater occipital nerve, greater occipital artery, ...."
Code:
suboccipital triangle, A: vertebral, N: suboccipital, N: g occipital, A: g occipital,...
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!