andgineer / TRegExpr

Regular expressions (regex), pascal.
https://regex.sorokin.engineer/en/latest/
MIT License
174 stars 63 forks source link

fix code duplication here #194

Closed Alexey-T closed 4 years ago

Alexey-T commented 4 years ago
            '=':
              begin
                // lookahead: foo(?=bar)
                if (regparse + 3 >= fRegexEnd) then
                  Error(reeLookaheadBad);
                GrpKind := gkLookahead;
                regLookahead := True;
                regLookaheadGroup := regnpar;

                // check that these brackets are last in regex
                SavedPtr := _FindClosingBracket(regparse + 1, fRegexEnd);
                if (SavedPtr <> fRegexEnd - 1) then
                  Error(reeLookaheadBad);

                Inc(regparse, 2);
              end;
            '!':
              begin
                // lookahead negative: foo(?!bar)
                if (regparse + 3 >= fRegexEnd) then
                  Error(reeLookaheadBad);
                GrpKind := gkLookaheadNeg;
                regLookahead := True;
                regLookaheadNeg := True;
                regLookaheadGroup := regnpar;

                // check that these brackets are last in regex
                SavedPtr := _FindClosingBracket(regparse + 1, fRegexEnd);
                if (SavedPtr <> fRegexEnd - 1) then
                  Error(reeLookaheadBad);

                Inc(regparse, 2);
              end;
Alexey-T commented 4 years ago

Fixed in pull req.