0

I have a string likes below

a_b_c_d

I hope to decode it to an array t as

t[0]->a
t[1]->b    
t[2]->c
t[3]->d

Just wonder if there ia function of javascript can parse the string directly.

arachide
  • 8,006
  • 18
  • 71
  • 134

2 Answers2

3
var string = "a_b_c_d";
var t = string.split('_');

DEMO FIDDLE

Kiran
  • 20,167
  • 11
  • 67
  • 99
0

Just split the string

var t = "a_b_c_d".split("_");
Shanimal
  • 11,517
  • 7
  • 63
  • 76