RegexFuck is a super set of RegEx that implements Brainfuck as well. This allows for easy counting in matches. For example you can easily find the closing parenthesis that belongs to an opening one but just incrementing a value each time an opening one is matched and decrementing it every time a closing one is matched: