When you use capturing parentheses in your regular expression, it adds an item to the returned results array for the overall match and each set of capturing parentheses.
matchArr[0] is everything that was matched.
matchArr[1] is what matches in the first set of capturing parentheses
matchArr[2] is what matches in the second set of capturing parentheses
and so on
So, in your regex /^([^#]+)/, there is no difference between matchArr[0] and matchArr[1] because everything that matches is in the capturing parentheses.
If you did this:
var str = 'some string';
var rexp = /^some([^#]+)/;
var matchArr = str.match(rexp);
You would find that:
matchArr[0] == "some string";
matchArr[1] == " string";
because there are parts of the match that are not in the capturing parentheses.
Or if you did this:
var str = 'some string';
var rexp = /^(some)([^#]+)/;
var matchArr = str.match(rexp);
You would find that:
matchArr[0] == "some string";
matchArr[1] == "some"
matchArr[2] == " string";