Then replace the clipboard contents with a stored string of code, replacing just the lines of code between the stratString and endString with my storedString? Better yet would be to replace the start and end strings as well. But it has to know where to begin and end.
Or maybe, there’s a post that somebody knows of that explains how this could be achieved?
set theClip to the clipboard
set endString to "<!-- Address 9 End"
set theStart to offset of "<!-- Address 1 Start" in theClip
set theEnd to offset of endString in theClip
set theClip to text 1 thru (theStart - 1) of theClip & "<!-- replacement text here..." & text (theEnd + (length of endString)) thru -1 of theClip
set the clipboard to theClip
Once again, this is superb. I have an additional and probably easy question.
What is the fastest way to verify if a string exists within the clipboard set to text?
For example, I would like to throw and error if the clipboard does not contain:
“<!-- Address 1 Start”
or
“<!-- Address 9 End”
Do I have to use text item delimiters? - Which is fine, if I have to. I just am not sure if there is a more optimal way.
Good grief. I tried that in the past with no success. Needless to say, the document I was copying to the clipboard was flawed, skewing my find results. Thank you so much Yvan for making me look deeper and detecting the issue and allowing me to use this simple clean code. I can’t thank you both enough for the help you provide me.