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

Answer by Sean Bright for Get everything after the dash in a string in JavaScript

$
0
0
var the_string = "sometext-20202";var parts = the_string.split('-', 2);// After calling split(), 'parts' is an array with two elements:// parts[0] is 'sometext'// parts[1] is '20202'var the_text = parts[0];var the_num  = parts[1];

Viewing all articles
Browse latest Browse all 15

Trending Articles