File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Anyone know regular expressions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Anyone know regular expressions?" Watch "Anyone know regular expressions?" New topic

Anyone know regular expressions?

Robert Willems
Ranch Hand

Joined: Apr 14, 2003
Posts: 32
Hi everybody,
i'm using regular expressions to filter thing from a String.
Can a regular expression be recursive?
I need a expression (that works in org.apache.regexp.RE) that parses something like a function. A function starts with '${' and ends with '}'. But in the text between there can also be new 'instances' of ${...}
When parsing the string "bla bla${bla ${bla} ${bla}}bla ${bla} bla" the first thing the epxression needs to give me is "${bla ${bla} ${bla}}"
I'm not very good with expression and have been using \$\{.+?\} as an expression at the moment, but that wont give me the right results.
Does anybody have a good idea for a working expression? Or should i be writing my own parsing routine?
Thanks in advance,
Robert Willems

Regards,<br />Robert Willems of Brilman<br /> <br />----------------------<br /> <br />SCJP 1.4<br />SCWCD 1.3<br />SCWCD 1.4 (beta)<br />SCDJWS 1.4 (beta)<br />SCBCD 1.3 (studying)
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

moving this to the Java In General (Intermediate) forum for two reasons:
1- this isn't a very advanced question.
2- Max Habibi is a moderator there and he wrote a whole book on Regular Expressions!
I agree. Here's the link:
subject: Anyone know regular expressions?
It's not a secret anymore!