place private function in closure

also changed function name from jsPregMatchAll() to preg_match_all() to
fit phpjs norm