Quantcast
Channel: Get everything after the dash in a string in JavaScript - Stack Overflow
Viewing all articles
Browse latest Browse all 15

Answer by Mahyar Ekramian for Get everything after the dash in a string in JavaScript

$
0
0

With built-in javascript replace() function and using of regex (/(.*)-/), you can replace the substring before the dash character with empty string (""):

"sometext-20202".replace(/(.*)-/,""); // result --> "20202"

Viewing all articles
Browse latest Browse all 15

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>