"Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems."
--Jamie Zawinski, in comp.lang.emacs
I think Erich is right - a simple parser seems like the better answer for you in this case.
cheers,
-don