It is possible to call match method on the string in order to retrieve the whole collection of matches:
var ptrn = /[a-zA-Z_][a-zA-Z0-9_]*|'(?:\\.|[^'])*'?|"(?:\\.|[^"])*"?|-?[0-9]+|#[^\n\r]*|./mg;
var results = "hello world".match(ptrn);
results are (according to the regular expression):
["hello", " ", "world"]
match spec is here