On Wed, Feb 16, 2011 at 2:55 PM, ken <gebser@mousecar.com> wrote:
(setq dog (buffer-substring
 (re-search-backward "<h1\\|<h2\\|<h3\\|<h4\\|<h5" nil t)
 (re-search-forward "</h1>\\|</h2>\\|</h3>\\|</h4>\\|</h5>" nil t)))

What mode are you using to edit html?  What version of Emacs?  It's likely your major-mode supports balanced tag movements, so this hacky regexp searching isn't necessary.

What do you want o do with the saved text?  Why don't you try to compose the function to the best of your ability, and I'm sure someone will give you hints for what you can't get working.

--
Le