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
  • 7,898
  • 17
  • 68
  • 131

2 Answers2

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

DEMO FIDDLE

Kiran
  • 19,739
  • 10
  • 64
  • 98
0

Just split the string

var t = "a_b_c_d".split("_");
Shanimal
  • 11,317
  • 7
  • 61
  • 72