我想做以下帮助我制作这个剧本:
if form text include = "ABC" (for example: "Whatever words ABC")
then delete the word "ABC" (so it become "Whatever words")
AND
if form text doesn't include = "ABC"
then add the word at the end "ABC (so it become "Whatever words ABC")
请注意:我不想触及所包含的字符串只有"ABC"
的部分字符串,或者只删除此部分。
我希望你能理解。
我需要此脚本才能在iMacros(网络自动化软件)下工作
已解决: SET !VAR2 EVAL("'{{!EXTRACT}}'.includes('ABC') ? '{{!EXTRACT}}'.replace('ABC','') : '{{!EXTRACT}} ABC';")
答案 0 :(得分:1)
试试这个:
var str = "Whatever words ABC";
if (str.indexOf('ABC') !== -1)
str.replace('ABC', '')
else
str+= ' ABC'
答案 1 :(得分:0)
试试这个
var str ="ABCDEFGHI"
if(str.indexOf("ABC") !== -1){
str.replace(/ABC/g,"")
}else{
str=str+"ABC"
}
答案 2 :(得分:0)