Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个快速的问题
我有字符串var str="0-12345";
var str="0-12345";
如果 Javascript 中有一个破折号,我如何才能真正从字符串中删除破折号。如何检查字符串是否有破折号,如果有,则从中删除破折号?
你在这里问之前忘了做功课,无论如何
var str="0-12345"; var is_dashed=(str.indexOf("-") !== -1); str= str.replace('-',''); //many more ideas , it seems simple to remove all '-'