I am looking for a way to assign a variable to a “word” that has already been found and selected in InDesign CS2. The only characters of the word “myDateRange” I want assigned to that variable are the characters: ^9 or “/”
The problem is, sometimes “myDateRange” ends with a period or a comma, or any other random punctuation mark that I don’t want to be part of the word.
For example, I only want the variable to be the numbers or slashes: “9/9/99”
I will be looking into brushing up my knowledge of using text delimeters but I am not very good at this. I haven’t touched scripting in awhile, so I thought somebody may be able to help in the meantime?
More than likely there is an easier way to do this
but if I understand you correctly this should work.
This script grabs the last char of the myDateRange
and compares it to the numbers string list. If it
finds a number myDateRange stays the same. If
if does not, it removes the last char from
myDateRange.
set filterList to {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
set myDateRange to "9/9/99."
set dateOnly to false
repeat with i from 1 to count the filterList
set thisItem to item i of filterList
set lastChar to text -1 of myDateRange
if thisItem = lastChar then
set dateOnly to true
exit repeat
end if
end repeat
if dateOnly is false then
set myDateRange to text 1 thru -2 of myDateRange
end if