Split string in Javascript with _ -
i beginner javascript.i want create array 1,2,3,4,5
but o/p ,1,2,3,4,5
i tried .split() in javascript not getting required output.
var string="testrating_1testrating_2testrating_3testrating_4testrating_5"; var temp = new array(); temp = string.split("testrating_"); (a in temp ) { temp[a] = temp[a]; }
fiddle
you way:
var string = "testrating_1testrating_2testrating_3testrating_4testrating_5", temp = string.split('testrating_'); temp.shift(); //remove fist item empty console.log(temp); //["1", "2", "3", "4", "5"]
Comments
Post a Comment