我想捕捉两个$符号之间的内容。 例如: - 这只是$ $ $示例$所以$快速回复$。 在这里,我想将美元(仅限,快速)之间的文本存储到数组中。 在使用此代码进行捕获时。但它捕获(只是一个例子,因此,快速响应)。我需要“只”,“如此”和“快速”。
replace "\$" with "\XXdollarXX" in field "MytextField"
put the text of field "MytextField" into ss
repeat with i = 0 to the number of chars in ss
if char i of ss contains "$" then
repeat with x = i+1 to the number of chars in ss
if char x of ss contains "$" then
--answer x
put x into Lpos
put char i to Lpos of ss into jar
answer jar
put Lpos into i
end if
end repeat
end if
end repeat
答案 0 :(得分:0)
如果您在单步执行时检查代码,您将看到必须以这种方式工作。 "偏移"但是,函数可以在循环中使用,并包含一个参数" chars to skip"。通过不断更新该参数,并考虑到只有其他每个实例都是相关的,您可以在" $"之间收集文本。为:
制作一个按钮和一个字段。将一些文字放入洒满" $"用于检测。在按钮脚本中:
on mouseUp
put 0 into charsToSkip
repeat until charsToskip > the length of fld 1
if the optionKey is down then exit to top --YOU WILL NEED THIS RIGHT NOW...
get offset("$",fld 1,charsToSkip)
add it to charsToSkip
put charsToSkip & return after accum
end repeat
end mouseUp
我留给你添加正确退出此循环的功能。逐步执行处理程序,您将以我提到的方式看到accum building中的值。
克雷格纽曼