帮助JavaScript替换

时间:2011-08-29 22:49:11

标签: javascript regex

var isbn = '978-0393317558';
alert(isbn.replace(/^[^0-9]+/, '')); //this gives the same value

为什么不更换破折号?

1 个答案:

答案 0 :(得分:4)

因为第一个^强制匹配位于字符串的开头。