রেগুলার এক্সপ্রেশন এবং match() মেথড ব্যবহার করে স্কয়ার ব্র্যাকেটের ভেতরের মান বের করা যায়।
উদাহরণ
var regularExpression = /(?<=\[).*?(?=\])/g;
var getTheValueWithIndex = "[John Smith][David Miller]".match(regularExpression);
console.log("The first value without bracket=" + getTheValueWithIndex[0]);
console.log("The second value without bracket=" + getTheValueWithIndex[1]);
কমান্ড: node fileName.js
আউটপুট
PS C:\Users\Amit\JavaScript-code> node demo132.js The first value without bracket=John Smith The second value without bracket=David Miller