I am developing a programe search & Replace text in a quark document. Please check my code it is working fine. only I want some enhancement in it. I want search & reaplcae should be done for CASE SENSITIVE & WHOLE WORD.
tell application "QuarkXPress"
activate
tell document 1
set TheStories to count of every story
repeat with i from 1 to TheStories
set mysearch to (a reference to (text of story i whose contents of it = "Rajeev"))
set contents of mysearch to "Kumar"
end repeat
end tell
end tell
At present it replace fine but if there is a string “Rajeeveer” then it get replaced by “Kumareer”, which I don’t want.
I experimented a bit and this was the best I could come up with:
tell application "QuarkXPress"
activate
tell document 1
set TheText to count of every text box
repeat with i from 1 to TheText
tell story 1 of text box i
set (every text where it is "Rajeev ") to "Kumar "
set (every text where it is "Rajeev.") to "Kumar."
--copy addition conditions here
end tell
end repeat
end tell
end tell
This will not change “Rajeeveer”. You can copy the second condition:
set (every text where it is “Rajeev.”) to “Kumar.”
as many more times as you need to account for additional punctuation:
set (every text where it is “Rajeev?”) to “Kumar?”
set (every text where it is “Rajeev!”) to “Kumar!”
etc…