Regular Expressions

P

Picho

Hi all,

first of all, does anyone know of a newsgroup dedicated for regular
expressions?

second - my problem:

I have a string that represents a formula of the format: "formula(...)"
the formula itself can contain other formula expressions like "Calc(...)",
"Assign(...)" etc
these expressions can be nested i.e "Calc(Assign(...), Formula(...))"
of course the expression is not limited in length, nesting levels or
complexity.

my goal is to extract the elements as groups.

I narrowed my problem down to this:

lets say "Calc(...)" can calc any mathematical expression as in
"Calc(5*(2+1))". is there any way to "count" the "()" to find the closing
")" of the calc expression and extracting it in a group?

Thanks,

Picho
 
C

Chris R. Timmons

Hi all,

first of all, does anyone know of a newsgroup dedicated for
regular expressions?

second - my problem:

I have a string that represents a formula of the format:
"formula(...)" the formula itself can contain other formula
expressions like "Calc(...)", "Assign(...)" etc
these expressions can be nested i.e "Calc(Assign(...),
Formula(...))" of course the expression is not limited in
length, nesting levels or complexity.

my goal is to extract the elements as groups.

I narrowed my problem down to this:

lets say "Calc(...)" can calc any mathematical expression as in
"Calc(5*(2+1))". is there any way to "count" the "()" to find
the closing ")" of the calc expression and extracting it in a
group?

Picho,

One thing regular expressions cannot generally do is parse nested
data structures. .Net regexes have a limited ability to do this,
but, IMHO, it's more trouble than it's worth.

A much better approach to parsing nested data structures is to use a
real parser. An excellent free tool for this is called ANTLR:

http://www.antlr.org/

Hope this helps.

Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top