2

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);

3 Answers 3

4

You should parse that as JSON:

var array = JSON.parse(input);
alert(array[0]);
Sign up to request clarification or add additional context in comments.

Comments

1

This should get you an array of all the matches

var matches = mystring.match(/\[\"(.*?)\"\]/g);

Comments

0

Try this :

//variable contains ["IBM"]
variable = variable.substr(2,3);

This will work only if the text between the [""] length is 3

1 Comment

Lol, i admit it's a little bit lazy :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.