替換代碼不能用於單引號,請幫助我。 有些地方它正在工作,有些地方不起作用。替換代碼的單引號不起作用
JavaScript代碼:
var demo = "Broadcasted on Zee TV from Monday to Friday, the Indian television soap opera Kumkum Bhagya has long been revolving around the mystery of Tanu’s pregnancy. Tanu, a cunning, sly and guileful character in the Kumkum Bhagya serial has been fooling Abhi, the rock star. She is actually pregnant with Nikhil, her ex-boyfriend, but claims to be the mother of Abhi’s child. Except Abhi, almost everyone in the show knows who Tanu is pregnant with. But, the mystery will remain unrevealed until Abhi knows the reality of Tanu’s pregnancy. The coming episodes of Kumkum Bhagya, Pragya's DNA disclosure is likely to reveal the secret.";
var demo1 = demo.replace(/[']/g,";");
//alert(demo1);
document.getElementById("hello").innerHTML = demo1;
HTML代碼:
<div id="hello">
</div>
請以此爲參考: https://jsfiddle.net/h3sujuLx/
在示例文本和替換函數中不使用相同的字符。它們都是撇號,它們都有不同的字符代碼,所以函數找不到匹配。 – Nekomajin42
但親愛的,我想要在同一個文檔中處理這兩個問題,因爲當我使用request.getParameter方法在java中獲取該字符串時,撇號從字符串中消失。 那麼,告訴我如何處理這個問題? –
我認爲@Duncan的解決方案將起作用。 – Nekomajin42