簡體   English   中英

如何刪除Javascript字符串中所有出現的字符'?

[英]How to remove all occurrence of character ' in a string in Javascript?

我的字符串就像(乘客的名字是Suraj,乘客的聯系電話是XXXXXXX672 )。 如何從字符串中刪除出現的'? 我嘗試使用

comments = comments.replace(/'/g, ' '); and comments = comments.replace(/\'/g, ' ');

但是他們沒有用。 請建議我有需要。

您的密碼

var temp = "passenger's name is Suraj and passenger's contact number is    XXXXXXX672";
var test = temp.replace(/'/g, ' ');

產量

"passenger s name is Suraj and passenger s contact number is XXXXXXX672"

它的工作正常。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM