为什么使用替换而不是替换给我不好的结果?
我仍在研究我的IDE,我一直遇到问题,我想知道我是否只是继续做错了什么,这是我需要帮助的代码示例
function updatesrcnow(){
document.getElementById("editordiv").innerHTML = document.getElementById("editordiv").innerHTML.replaceAll("pubvar()","<mathcode>pubvar()</mathcode>").replaceAll("math.","<mathcode>math.</mathcode>").replaceAll(".random","<mathcode>.random</mathcode>").replaceAll("+","<mathcode>+</mathcode>").replaceAll("-","<mathcode>-</mathcode>").replaceAll("/","<mathcode>/</mathcode>").replaceAll("*","<mathcode>*</mathcode>").replaceAll(".percent","<mathcode>.percent</mathcode>").replaceAll("1","<mathcode>1</mathcode>").replaceAll("2","<mathcode>2</mathcode>").replaceAll("3","<mathcode>3</mathcode>").replaceAll("4","<mathcode>4</mathcode>").replaceAll("5","<mathcode>5</mathcode>").replaceAll("6","<mathcode>6</mathcode>").replaceAll("7","<mathcode>7</mathcode>").replaceAll("8","<mathcode>8</mathcode>").replaceAll("9","<mathcode>9</mathcode>").replaceAll("0","<mathcode>0</mathcode>");
document.getElementById("editordiv").innerHTML = document.getElementById("editordiv").innerHTML.replaceAll("select()","<objcode>select()</objcode>").replaceAll("getobjid()","<objcode>getobjid()</objcode>").replaceAll("objectRun()","<objcode>objectRun()</objcode>").replaceAll("create()","<objcode>create()</objcode>").replaceAll("destroy()","<objcode>destroy()</objcode>").replaceAll("transform","<triggercode>transform</triggercode>").replaceAll(".object","<objcode>.object</objcode>").replaceAll(".Translate","<objcode>.Translate</objcode>").replaceAll(".v2","<objcode>.v2</objcode>").replaceAll(".change()","<mathcode>.change()</mathcode>").replaceAll(".height","<objcode>.height</objcode>").replaceAll(".width","<objcode>.width</objcode>").replaceAll(".design","<objcode>.design</objcode>");
document.getElementById("editordiv").innerHTML = document.getElementById("editordiv").innerHTML.replaceAll("using.","<triggercode>using.</triggercode>").replaceAll("world.","<triggercode>world.</triggercode>");
}
#editordiv{
background: black;
color: white;
}
positioncode{
color: #00c3ff;
}
triggercode{
color: #f0ad44;
}
punctcode{
color: #c81305;
}
objcode{
color: #00d839;
}
boolcode{
color: #e3fe53;
}
mathcode{
color: #ff0096;
}
cameracode{
color: #bcbcbc;
}
<link rel="alternate" type="application/json+oembed" href="/oembed.json" title="Rag3D - Home Of Ragolation"/>
<script src="/app-home/editor/ragstor.js"></script>
<div id="fileholder"></div> <div id="editordiv" contenteditable="true"></div>
我只是想知道考虑到我看不到问题的问题是否有更多的方法来制作颜色代码,或者我只是做错了什么,我做错了什么。
I'm still working on my IDE and I keep running into problems and I'm wondering if I just keep doing something wrong this is the sample of code that I need help with
function updatesrcnow(){
document.getElementById("editordiv").innerHTML = document.getElementById("editordiv").innerHTML.replaceAll("pubvar()","<mathcode>pubvar()</mathcode>").replaceAll("math.","<mathcode>math.</mathcode>").replaceAll(".random","<mathcode>.random</mathcode>").replaceAll("+","<mathcode>+</mathcode>").replaceAll("-","<mathcode>-</mathcode>").replaceAll("/","<mathcode>/</mathcode>").replaceAll("*","<mathcode>*</mathcode>").replaceAll(".percent","<mathcode>.percent</mathcode>").replaceAll("1","<mathcode>1</mathcode>").replaceAll("2","<mathcode>2</mathcode>").replaceAll("3","<mathcode>3</mathcode>").replaceAll("4","<mathcode>4</mathcode>").replaceAll("5","<mathcode>5</mathcode>").replaceAll("6","<mathcode>6</mathcode>").replaceAll("7","<mathcode>7</mathcode>").replaceAll("8","<mathcode>8</mathcode>").replaceAll("9","<mathcode>9</mathcode>").replaceAll("0","<mathcode>0</mathcode>");
document.getElementById("editordiv").innerHTML = document.getElementById("editordiv").innerHTML.replaceAll("select()","<objcode>select()</objcode>").replaceAll("getobjid()","<objcode>getobjid()</objcode>").replaceAll("objectRun()","<objcode>objectRun()</objcode>").replaceAll("create()","<objcode>create()</objcode>").replaceAll("destroy()","<objcode>destroy()</objcode>").replaceAll("transform","<triggercode>transform</triggercode>").replaceAll(".object","<objcode>.object</objcode>").replaceAll(".Translate","<objcode>.Translate</objcode>").replaceAll(".v2","<objcode>.v2</objcode>").replaceAll(".change()","<mathcode>.change()</mathcode>").replaceAll(".height","<objcode>.height</objcode>").replaceAll(".width","<objcode>.width</objcode>").replaceAll(".design","<objcode>.design</objcode>");
document.getElementById("editordiv").innerHTML = document.getElementById("editordiv").innerHTML.replaceAll("using.","<triggercode>using.</triggercode>").replaceAll("world.","<triggercode>world.</triggercode>");
}
#editordiv{
background: black;
color: white;
}
positioncode{
color: #00c3ff;
}
triggercode{
color: #f0ad44;
}
punctcode{
color: #c81305;
}
objcode{
color: #00d839;
}
boolcode{
color: #e3fe53;
}
mathcode{
color: #ff0096;
}
cameracode{
color: #bcbcbc;
}
<link rel="alternate" type="application/json+oembed" href="/oembed.json" title="Rag3D - Home Of Ragolation"/>
<script src="/app-home/editor/ragstor.js"></script>
<div id="fileholder"></div> <div id="editordiv" contenteditable="true"></div>
I'm just wondering what I did wrong considering I don't see the problem is there a more sufficient way to do color code or am I just doing it wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论