开发者

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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜