• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Anyone know regular expressions?

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ${...}
Eg.
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
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Hold that thought. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic