【发布时间】:2018-04-16 15:02:37
【问题描述】:
我有这样的 XML 内容
<abc:content><bcd:position>Just text: node not need to replace</abc:content>
我需要将其替换为
<abc:Content><bcd:Position>Just text: node not need to replace</abc:Content>
在 SublimeText 或 Notepad++ 中,如果我搜索,我可以用正则表达式替换它
:. or :\b(\w) or :\b.
替换成
:\U$1
它工作正常。但是我不能用
string.replace(/:\b./g , ':\U$1');
这不能正常工作!如果我尝试使用 ':$1'.toUpperCase() 它仍然没有给出正确的结果 - 这用于其他问题,并且不适合我。 请帮帮我!
【问题讨论】:
-
变量js是你的字符串值吗?如果没有:在你的字符串上使用 replace 方法。
-
我总是把它转换成字符串
标签: javascript regex replace