In implementing a small script parser I've come across a problem with this sample of code - in wanting to select only the part between and including the "if { }" statements, it's being greedy and selecting all including the last line. I guess what I should be using is a negative lookahead.
if [condition1]
{
task1
setparameters{a}
task2
}
if [condition2]
{
task3
}
setparameters{b}
Currently, I have:
if\b\s\[.*\]\s\{(\s|.)*\}
I guess it's not as simple as breaking on another 'if' either, as something else may come before then. Is it possible to count an equal number of opening and closing braces? Or is there some other magical way that I can just select one of these 'if' statements?