Get everything after the dash in a string in javascript

前端 未结 9 2068
故里飘歌
故里飘歌 2020-11-30 22:47

What would be the cleanest way of doing this that would work in both IE and firefox.

My string looks like this: sometext-20202

Now the \'sometext\' and the

9条回答
  •  情书的邮戳
    2020-11-30 23:13

    AFAIK, both substring() and indexOf() are supported by both Mozilla and IE. However, note that substr() might not be supported on earlier versions of some browsers (esp. Netscape/Opera).

    Your post indicates that you already know how to do it using substring() and indexOf(), so I'm not posting a code sample.

提交回复
热议问题