如何克服与此相关的问题。 我需要在myHtml中将“snn”替换为“”&“sss”和“”。 它将用“sss”替换所有“snn”。 但它不会在行的开头(换行符,\ n)起作用。
How to overcome the issue relating this replaces. I need to replace " snn" with "" & " sss" & "" in myHtml. it will replace all " snn" with " sss". but it will not work in the begin of a line(newline, \n).
最满意答案
我们假设我们有以下数据
那个男人站在地板上 男人等
在字段1.我们可以使用以下语法替换任何出现the或者或space & the或linefeed & the
on mouseUp put word 1 to -1 of replaceText(space & fld 1,"[\n ][tT]he "," an ") end mouseUp注意额外的前面空格,使用word 1 to -1再次删除。
不幸的是,这种语法用空格替换了换行符。 我不知道你是否想要这个。 如果没有,我建议使用两行,一行用于空格,一行用于换行。
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总是用“an”代替“the”对我来说似乎有点奇怪,但它确实是你所要求的。
Let's assume we have the following data
the man stands on the floor The man etc
in field 1. We can replace any occurrence of the or The or space & the or linefeed & the with an using the following syntax
on mouseUp put word 1 to -1 of replaceText(space & fld 1,"[\n ][tT]he "," an ") end mouseUpNote the extra preceding space, which is removed again using word 1 to -1.
Unfortunately, this syntax replaces linefeeds with spaces. Id on't know if you want this. If not, I'd suggest using two lines, one for space and one for linefeed.
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 mouseUpIt seems a little strange to me to always replace "the" with "an" but it does what you're asking for.
更多推荐
发布评论