Jacek Laskowski 57 Posted March 23, 2020 (edited) I need to enable preUnGreedy option in TRegEx, PCRE supports this parameter: unit System.RegularExpressionsCore; interface [...] type TPerlRegExOptions = set of ( preCaseLess, // /i -> Case insensitive preMultiLine, // /m -> ^ and $ also match before/after a newline, not just at the beginning and the end of the string preSingleLine, // /s -> Dot matches any character, including \n (newline). Otherwise, it matches anything except \n preExtended, // /x -> Allow regex to contain extra whitespace, newlines and Perl-style comments, all of which will be filtered out preAnchored, // /A -> Successful match can only occur at the start of the subject or right after the previous match preUnGreedy, // Repeat operators (+, *, ?) are not greedy by default (i.e. they try to match the minimum number of characters instead of the maximum) preNoAutoCapture // (group) is a non-capturing group; only named groups capture ); But the PCRE parameters are set by mapping: constructor TRegEx.Create(const Pattern: string; Options: TRegExOptions); begin FOptions := Options; FRegEx := TPerlRegEx.Create; FRegEx.Options := RegExOptionsToPCREOptions(FOptions); <--- mapping PCRE params to Delphi TRegEx if (roNotEmpty in Options) then FRegEx.State := [preNotEmpty]; FRegEx.RegEx := Pattern; FNotifier := TScopeExitNotifier.Create(FRegEx); if (roCompiled in FOptions) then FRegEx.Compile; end; And for a reason unknown to me, this parameter was omitted: function RegExOptionsToPCREOptions(Value: TRegExOptions): TPerlRegExOptions; begin Result := []; if (roIgnoreCase in Value) then Include(Result, preCaseLess); if (roMultiLine in Value) then Include(Result, preMultiLine); if (roExplicitCapture in Value) then Include(Result, preNoAutoCapture); if roSingleLine in Value then Include(Result, preSingleLine); if (roIgnorePatternSpace in Value) then Include(Result, preExtended); end; Bug? Is there any way to solve this? Delphi 10.3 Edited March 23, 2020 by Jacek Laskowski Share this post Link to post
pyscripter 694 Posted March 23, 2020 See workaround in https://quality.embarcadero.com/browse/RSP-22372. 1 Share this post Link to post
stijnsanders 36 Posted February 22 The site is asking me to log in (into Jira??!!) Can you post here what the workaround is? Share this post Link to post
pyscripter 694 Posted February 23 (edited) See the record helpers in https://github.com/pyscripter/Pcre-Jit-Delphi/blob/master/Demos/benchmark.dpr and the methods SetAdditionalPCREOptions Edited February 23 by pyscripter 1 Share this post Link to post