Wumbate
New User
May 7, 2008, 10:34 PM
Post #1 of 4
(7913 views)

A way to check for "matching" characters?

Can't Post


Hi, I'm trying to write a regular expression to mark up equations to HTML. Here is an example: 2^3 should become 2<sup>3</sup> and a_b should become a<sub>b</sub> However, I'm having trouble getting more complicated equations to properly work. For instance: 3^(1+(5*2)+3) should become 3<sup>1+(5*2)+3</sup> The problem I'm having is that I need to match starting parentheses ( with ending parentheses ), while ignoring any other parentheses that may occur in the middle. Is there a good regular expression way to do this? PS  This is my first post here, so thanks in advance.
