用多个覆盖字符串替换字符串

时间:2017-11-06 15:13:56

标签: javascript regex

我有node_file <- system.file("./node_script.sh", package = "mypackage") Sys.chmod(node_file, mode = "0555") system(node_file)

之类的字符串

上面的字符串应该像“string lower lower case

它的小写和小写应该是粗体。

1 个答案:

答案 0 :(得分:0)

您可以使用正则表达式在HTML中执行此操作:

<div id="text"></div>
<script>
  var str = "string lower and lower case"; // You can't have const.
  text.innerHTML = str.replace(/(lower (case)?)/g, '<strong>$1</strong>');
</script>