Reputation: 101
need to extract the string from this ["IBM"], have to get IBM, I have tried like this
(/['"]/g,'') way.
var extractor=(/['"]/g,'');
var newArr = extractor.exec(NAME);
alert(newArr);
Upvotes: 2
Views: 77
Reputation: 180
This should get you an array of all the matches
var matches = mystring.match(/\[\"(.*?)\"\]/g);
Upvotes: 1
Reputation: 545
Try this :
//variable contains ["IBM"]
variable = variable.substr(2,3);
This will work only if the text between the [""] length is 3
Upvotes: 0
Reputation: 887285
You should parse that as JSON:
var array = JSON.parse(input);
alert(array[0]);
Upvotes: 4