I get size of the PDF files within the name of the the file on page
console.log($(opt).text() + " selected")
opt has the value such as abcs{853269}
I get the value using regular expression:
var curSize = $(opt).text();
console.log(curSize + "current Size");
var counter = 0;
var result = curSize.match(/{(.*?)}/);
console.log('sizee' + result);
The console result is {853269},853269
I don't know why I am getting two results, I thought regex will only return one.
Now I have a for loop to calculate all the values that are selected and give it back to me as one big sum:
if ( result !=null){
for(var i=0; i< result.length; i++){
counter += result[i];
document.getElementById("textarea").value += result[i];
}
console.log(counter + "Counter");
}
...but it's crashing.
result[0]is the whole match, and the rest of the elements are the contents of the capturing groups.result[1]is what you want.