我需要在特定字符串之后和之前进行某些替换。示例:我需要"用良好的字段替换错误" MytextField""。但是这个替换应该在begin {document}之后和end {document}之前完成。在开始{document}之前和结束{document}之后,没有任何单词替换。这怎么可能?。 如果我使用这个代码"用good in field" MytextField""所有坏的时刻都应该被取而代之。我不需要改变整个领域。
答案 0 :(得分:2)
如果您的开始和结束标记只在字段中显示一次,那么这应该有效...
put wordOffset("begin{document}",fld "MytextField") into tBegin
put wordOffset("end{document}",fld "MytextField") into tEnd
put replaceText(word tBegin to tEnd of fld "MytextField","bad","good") into word tBegin to tEnd of fld "MytextField"
如果标记出现多次,则需要重复循环来逐步执行每个标记。
保
答案 1 :(得分:0)
将它放入一个字段:aa aa aa aa aa aa aa aa aa aa aa aa aa aa
将其放入按钮
local latest
on mouseUp
put 0 into latest
startFinding fld 1,0
end mouseUp
on startFinding tText,tOffset
if the optionKey is down then exit to top --just in case...
put wordOffset("red",fld 1,tOffset) into latest
answer "Change word" && (latest + tOffset) && "?" with "Change" or "Continue"
If it = "change" then put "green" into word (latest + tOffset) of fld 1
add latest to tOffset
if tOffset < the number of words of fld 1 then startFinding fld 1,tOffset
end startFinding