G
Guest
Can anyone help me with understanding the behaviour of a Regular Expression which is said to be like that of a stack?
It says in the docs...
"(?<group1-group2>) Balancing group definition. Deletes the definition of the previously defined group name2 and stores in group name1 the interval between the previously defined name2 group and the current group. If no group name2 is defined, the match backtracks. Because deleting the last definition of name2 reveals the previous definition of name2, this construct allows the stack of captures for group name2 to be used as a counter for keeping track of nested constructs such as parentheses. In this construct, name1 is optional."
I don't understand that unfortunately. Can anyone explain that better, preferably with a simple example?
Thanks!
It says in the docs...
"(?<group1-group2>) Balancing group definition. Deletes the definition of the previously defined group name2 and stores in group name1 the interval between the previously defined name2 group and the current group. If no group name2 is defined, the match backtracks. Because deleting the last definition of name2 reveals the previous definition of name2, this construct allows the stack of captures for group name2 to be used as a counter for keeping track of nested constructs such as parentheses. In this construct, name1 is optional."
I don't understand that unfortunately. Can anyone explain that better, preferably with a simple example?
Thanks!