Image

Imagecasufi wrote in Imageru_python

Помогите накрапать регулярку

Пишу на питоне скриптик, который поможет анализировать чужой код.
Есть конструкция вида

function Boolean CheckVINr(string vecode,LongInt minvinr)
BEGIN
  Boolean res;
  Boolean TrHs;
  record VIVc VIr;
  LongInt vinr;

  vinr = 0;
  TrHs = true;
  VIr.VECode = vecode;
  while (LoopKey("VECode",VIr,1,TrHs)) begin
    if (VIr.VECode!=vecode) then begin TrHs = false; end;
    if (TrHs) then begin
      vinr = vinr + 1;
      if (vinr>=minvinr) then begin
        res = true;
        goto LCheckVINr;
      end;
    end;
  end;
LCheckVINr:;
  CheckVINr = res;
  RETURN;
END;


Я пытаюсь написать регулярку, которая выдирала бы из текста кусок

while (LoopKey("VECode",VIr,1,TrHs)) begin
    if (VIr.VECode!=vecode) then begin TrHs = false; end;
    if (TrHs) then begin
      vinr = vinr + 1;
      if (vinr>=minvinr) then begin
        res = true;
        goto LCheckVINr;
      end;
    end;
  end;


Тобишь

(?s)(?m)(while \(LoopKey.*?(?Pif.*?(?P=ifgr).*?end;).*?end;)


Но у меня чет не получается, как правильно указать рекурсию ?