Refactored away from regular expression to using the parsing functionality from r.js