Regular Expressions

  • Thread starter Thread starter Picho
  • Start date Start date
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
 
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.
 
Back
Top