Let's talk about a JavaScript string scenario:
"h" + "e" + "l" + "l" + "o"
This particular string is extracted from a regex query, enclosed within [..], and here's how I'm isolating it:
var txt = '"blahblahblah["h"+"e"+"l"+"l"+"o"]foobarfoobarr"';
var re = /[^\[\]]+(?=\])/g;
var squareParen = re.exec(txt); // Result stored in squareParen[0]: ' "h" + "e".. etc'
// By assigning the string to a variable,
// I anticipated seeing its final output when logged
var result = squareParen[0];
console.log (result);
After posing a query here, my test proved that explicitly setting the string led to an expected console output of 'hello'. However, using the regex-assigned output gives me "h" + "e" + "l" + "l" + "o" instead of the combined "hello".
This situation has left me bewildered as to why.