我的字符串就像(乘客的名字是 Suraj,乘客的联系电话是XXXXXXX672)。如何从字符串中删除出现的 ' ?我尝试使用
comments = comments.replace(/'/g, ' '); and comments = comments.replace(/\'/g, ' ');
Run Code Online (Sandbox Code Playgroud)
但他们没有工作。请建议我有需要的。
你的代码
var temp = "passenger's name is Suraj and passenger's contact number is XXXXXXX672";
var test = temp.replace(/'/g, ' ');
Run Code Online (Sandbox Code Playgroud)
输出
"passenger s name is Suraj and passenger s contact number is XXXXXXX672"
Run Code Online (Sandbox Code Playgroud)
它的工作正常。
| 归档时间: |
|
| 查看次数: |
4986 次 |
| 最近记录: |