替换 livecode 中的问题
REplace issue in livecode
如何解决与此替换相关的问题。
我需要在 myHtml 中用“”&“sss”&“”替换“snn”。
它将用“sss”替换所有“snn”。但它不会在一行的开头工作(换行符,\n)。
假设我们有以下数据
the man stands on the floor
The man etc
在字段 1 中。我们可以使用以下语法将 the
或 The
或 space & the
或 linefeed & the
替换为 an
19=]
on mouseUp
put word 1 to -1 of replaceText(space & fld 1,"[\n ][tT]he "," an ")
end mouseUp
注意前面的额外内容 space,使用 word 1 to -1
再次将其删除。
不幸的是,此语法将换行符替换为 spaces。我不知道你是否想要这个。如果没有,我建议使用两行,一行用于 space,另一行用于换行。
on mouseUp
put replaceText(space & fld 1,"[\n]([tT]he) ",cr & "an ") into myTempVar
put word 1 to -1 of replaceText(myTempVar,"[ ]([tT]he) "," an ")
end mouseUp
总是将 "the" 替换为 "an" 对我来说似乎有点奇怪,但它确实满足了您的要求。
如何解决与此替换相关的问题。 我需要在 myHtml 中用“”&“sss”&“”替换“snn”。 它将用“sss”替换所有“snn”。但它不会在一行的开头工作(换行符,\n)。
假设我们有以下数据
the man stands on the floor
The man etc
在字段 1 中。我们可以使用以下语法将 the
或 The
或 space & the
或 linefeed & the
替换为 an
19=]
on mouseUp
put word 1 to -1 of replaceText(space & fld 1,"[\n ][tT]he "," an ")
end mouseUp
注意前面的额外内容 space,使用 word 1 to -1
再次将其删除。
不幸的是,此语法将换行符替换为 spaces。我不知道你是否想要这个。如果没有,我建议使用两行,一行用于 space,另一行用于换行。
on mouseUp
put replaceText(space & fld 1,"[\n]([tT]he) ",cr & "an ") into myTempVar
put word 1 to -1 of replaceText(myTempVar,"[ ]([tT]he) "," an ")
end mouseUp
总是将 "the" 替换为 "an" 对我来说似乎有点奇怪,但它确实满足了您的要求。