0

the string contains a value like this:

my string [[ [[test1]] test2 ]] other text

How I can get a values test1 and test2 in a different variables?

I tried!

var test = "my string [[ [[test1]] test2 ]] other text";

var reg = /[^\[\]]*[\w ]+(?=\])/i;
var reg2 = /\]\]\s*(.*)\s*\]\]/i;

result = reg2.exec(test);

​alert(result);​

The second regular I've made by myself, but it's still not the answer, it's returns me an array. So how to make it only a one value instead of whole array?

1
  • ok, where I can read about what I can to do with it? Commented Dec 27, 2012 at 17:18

1 Answer 1

1

use this regular experssion [^\[\]]*[\w ]+(?=\])

Sign up to request clarification or add additional context in comments.

2 Comments

Why are you just giving answers away? They haven't even shown any effort.
sorry, I even doesn't know what better to use, I know that javascript has not only a RegExp functions to make it.

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.