and you write your regex specifically for that document length, handling all possible nesting combinations. combinatoric explosion