How to remove `//<![CDATA[` and end `//]]>` with javascript from string?

后端 未结 3 1135
一个人的身影
一个人的身影 2021-01-17 18:40

How to remove // and end //]]> with javascript from string?

var title = \"

        
3条回答
  •  花落未央
    2021-01-17 18:57

    You can use the String.prototype.replace method, like:

    title = title.replace("", "");
    

    This will replace each target substring with nothing. Note that this will only replace the first occurrence of each, and would require a regular expression if you want to remove all matches.

    Reference:

    • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

提交回复
热议问题