P
Peter Szinek
Hello,
I need to match a chunk of code like this:
....
....
#begin here
...}
......end
...}
......}
.....end
...
...
I need to match from "the #begin here" up to the n-th closing token
(i.e. '}' or 'end'). n can be arbitrary (let's consider that it is
meaningful, i.e. there are no more '}' + 'end's than n.
Example
match_stuff(2):
#begin here
...}
......end
match_stuff(4):
#begin here
...}
......end
...}
......}
etc.
What's the most optimal way to accomplish this? I have been trying with
scan() but I did not really succeed yet
TIA,
Peter
__
http://www.rubyrailways.com
I need to match a chunk of code like this:
....
....
#begin here
...}
......end
...}
......}
.....end
...
...
I need to match from "the #begin here" up to the n-th closing token
(i.e. '}' or 'end'). n can be arbitrary (let's consider that it is
meaningful, i.e. there are no more '}' + 'end's than n.
Example
match_stuff(2):
#begin here
...}
......end
match_stuff(4):
#begin here
...}
......end
...}
......}
etc.
What's the most optimal way to accomplish this? I have been trying with
scan() but I did not really succeed yet
TIA,
Peter
__
http://www.rubyrailways.com