How can i catch the string right from the underscore?
I don't want the underscore to be part of the result.
the result should be:
this is a test
_this is a test
var re = /(?:_)(.*)/g;
var str = 'foo _this is a test';
m = re.exec(str)
Because you didn't just take the group 1 value. You take all of the Regex value instead. The code should be:
document.write(m); // m for taking group 1