Update preg_match_all.js

Placed private functions in a closure to avoid polluting the global scope.