matching curly braces and regular expressions

D

Dustin D.

Let's say I have a text file with the following:

food {
fruits {
apples
oranges
pears
}
dairy {
ice_cream {
chocolate
vanilla
}
milk
}
}

I want to use a regular expression to crop out the "dairy" section.
That is, I want to find the word dairy and count the curly braces, and
using this, crop out a part of a file.

Is there an easy way to do this with regular expressions? I wrote a
function that counts letters and so forth, but it's not full-proof and
has some problems.

Thanks,
Dustin
 

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top