in reply to Newbie seeking help.

Two of these problems are solved (exactly) in one line of code in jeffrey friedl's Mastering Regular Expressions.

brother dep.

--
Laziness, Impatience, Hubris, and Generosity.