如何替换livecode中的html文本

时间:2015-04-22 08:16:11

标签: livecode

我使用此代码替换带有相同单词的单词。它的工作正常。

replace Str[1] with  "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" in myHtml 

但当我更换它反之亦然它不起作用。我在使用此代码替换

replace "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" with Str[1] in myHtml 

2 个答案:

答案 0 :(得分:0)

您的代码实际上适合我。它会对第一个answer上的“def”进行打击和着色,但在第二个时它会恢复正常。也许你在逃避quotes时遇到了一些问题?

 put "abc def"  into myHtml
 put "def" into Str[1]
replace Str[1] with  "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" in myHtml
answer myHtml -- "def" is yellow and stroke
replace "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" with Str[1] in myHtml 
answer myHtml -- "def" is back to normal text

答案 1 :(得分:0)

带有两个按钮和一个文本字段的工作示例:

按钮1:

on mouseUp
put the htmlText of field "MytextField" into myHtml 
put item 1 of myhtml into str[1]
replace Str[1] with "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" in myHtml 
set the htmlText of fld "MytextField" to myHtml
end mouseUp

按钮2:

on mouseUp
put the htmlText of field "MytextField" into myHtml 
 put "abc" into str[1]
replace "<strike><font bgcolor=" & quote & "#FFFF00" & quote & ">" & Str[1] & "</font></strike>" with Str[1] in myHtml 
set the htmlText of fld "MytextField" to myHtml
end mouseUp

以及我如何设置文本域

set the htmltext of field "mytextfield" to "abc,def"