ivowel
1/23/2009 10:33:00 PM
Dear Experts: I am very new to ruby, literally having just read the
ruby book.
I want to write a program that does basic LaTeX parsing, so I need to
match '}' closings to the opening '{'. (yes, I understand that LaTeX
has very messy syntax, so this will only work for certain LaTeX docs.)
Does a gem exist that facilitates closing-paren-matching fairly
painlessly? For example,
sample = " \caption{my table \label{table-label} example:
$\sqrt{2+\sqrt{2}}$} more here {}"
so, I want to find my "\caption" matcher ruby program to be able to
detect the closing paren, and provide me with everything in between
the opener and closer (i.e., "my table \label{table-label} example:
$\sqrt{2+\sqrt{2}}$"). Possible?
I searched this mailing list first, but I only found discussions from
years back about this issue. I understand that this is not strictly
speaking a regular expression. I come from a perl background. There
are now some regex extension libraries that make it possible for the
built-in regex engine to parse matching parens
(Regexp::Common::balanced and Text::Balanced). I was hoping I could
find some similar gem for ruby.
help appreciated.
Sincerely,
/iaw