Get everything after the dash in a string in JavaScript

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 integer after the dash can be of varying length.

Should I just use substring and index of or are there other ways?

69 thoughts on “Get everything after the dash in a string in JavaScript”

  1. I’m not sure where you are getting your info, but good topic.
    I needs to spend some time learning much more or understanding more.
    Thanks for excellent info I was looking for this info for my

  2. Hi terrific website! Does running a blog similar to this take
    a large amount of work? I’ve virtually no knowledge of coding but I was hoping to start
    my own blog in the near future. Anyway, should you have
    any suggestions or tips for new blog owners please
    share. I know this is off subject nevertheless I simply needed to ask.


  3. Its like you learn my mind! You appear to know so much about this, like you wrote the ebook in it or something.
    I think that you simply can do with some % to drive the
    message house a little bit, however instead of that,
    that is fantastic blog. A fantastic read. I will
    definitely be back.

  4. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the
    post I realized it’s new to me. Nonetheless, I’m definitely delighted I found it and I’ll be book-marking and checking back often!

  5. Your style is really unique in comparison to other people I’ve read stuff from.
    I appreciate you for posting when you have the opportunity,
    Guess I will just book mark this site.

  6. This design is steller! You obviously know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to start my own blog (well,
    almost…HaHa!) Excellent job. I really enjoyed what you had to say,
    and more than that, how you presented it.

    Too cool! cheap flights cheap flights


Leave a Comment