Replacing shortcode paramaters

I am creating a widget which retrieves a post, looks for a particular shortcode, and if it finds it, extracts the attributes and content, replaces some of the content, and then calls the shortcode function to generate a particular result.

I can retrieve the posts and possibly use a regular expression to make sure the shortcode exists, but what is the best way to then parse the text into the attributes into an array and content into a string (like wordpress does)? Once I can do that, the rest should be easy.