使用 javascript 删除字符串中的特定字符

remove the specific character in the string using javascript

我的密码是:

function trim(str, characters) 
{
  var c_array = characters.split('');
  var result  = '';
  for (var i=0; i < characters.length; i++)
    result += '\' + c_array[i];
  return str.replace(new RegExp('^[' + result + ']+|['+ result +']+

并将此函数用作

trim(str,'[ ]');

正在通话中var tStr="[[[{"Name":"A","No":"8000444284"}],{"Name":"B","No":"8485990983"}],{"Name":"C","No":"0000000000"}]";

那是行不通的,请任何人帮助我...:)

, 'g'), ''); }

并将此函数用作

trim(str,'[ ]');

正在通话中var tStr="[[[{"Name":"A","No":"8000444284"}],{"Name":"B","No":"8485990983"}],{"Name":"C","No":"0000000000"}]";

那是行不通的,请任何人帮助我...:)

\[|\]

通过 empty string 尝试 this.Replace。查看演示。

https://www.regex101.com/r/fG5pZ8/4

var re = /\[|\]/g;
var str = '[[[{"Name":"A","No":"8000444284"}],{"Name":"B","No":"8485990983"}],{"Name":"C","No":"0000000000"}]';
var subst = '';

var result = str.replace(re, subst);