how to change '(1,2,3,4)' to '1,2,3,4'
this is my code:
var a='(1,2,3,4)'
a=a.sl开发者_JS百科ice(-1,1)
alert(a)
and i print nothing.
thanks
I think you want to do:
a = a.slice(1, -1);
a.substring(1,a.length-1)
1,2,3,4
What about :
'(1,2,3,4)'.replace(/[()]/g, '')
Which will remove all ( and ) characters in the string, giving you :
"1,2,3,4"
Another alternative:
var a='(1,2,3,4)';
a.replace(/^\((.*)\)$/, "$1");
精彩评论