Want to use PHP's preg_match_all() in Javascript ? that's what you need.