set tid to AppleScript's text item delimiters
tell application "QuarkXPress Passport"
tell front document
repeat with i from 1 to count of text boxes
my dotheSearch(i)
end repeat
end tell
end tell
set AppleScript's text item delimiters to tid
on dotheSearch(theTxtBoxNbr)
set delList to {"Chapter 1", "Chapter I", "Chapter one"} --and so on ..., you've got to fill the list ;-)
tell application "QuarkXPress Passport"
tell front document
set theStory to story 1 of text box theTxtBoxNbr
repeat with a from 1 to count of delList
if theStory contains item a of delList then
set AppleScript's text item delimiters to (item a of delList)
set theStoryList to every text item of theStory
set theCount to (count every word of item 1 of theStoryList) + 1
delete words theCount thru (theCount + 1) of story 1 of text box theTxtBoxNbr
set AppleScript's text item delimiters to " "
set theStory to story 1 of text box theTxtBoxNbr
set theStoryList to every text item of theStory
set theCount to (count every character of item 1 of theStoryList) + 1
delete character theCount of story 1 of text box theTxtBoxNbr
set AppleScript's text item delimiters to (item a of delList)
set theStory to story 1 of text box theTxtBoxNbr
set theStoryList to every text item of theStory
if (count of theStoryList) > 1 then my dotheSearch(theTxtBoxNbr)
end if
end repeat
end tell
end tell
end dotheSearch