From f731e2ddd9f5590673b12d8f0910265cc8f67f5b Mon Sep 17 00:00:00 2001 From: Constantin Piber Date: Fri, 15 Nov 2024 12:21:17 +0100 Subject: [PATCH] [#331] Re-introduce boundary check This improves the regex evaluation back to when we still had `\b` in front, while (hopefully) doing as it should --- src/DynamicExpresso.Core/Detector.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DynamicExpresso.Core/Detector.cs b/src/DynamicExpresso.Core/Detector.cs index e325397..3d58e01 100644 --- a/src/DynamicExpresso.Core/Detector.cs +++ b/src/DynamicExpresso.Core/Detector.cs @@ -12,10 +12,10 @@ internal class Detector private readonly ParserSettings _settings; private static readonly Regex RootIdentifierDetectionRegex = - new Regex(@"(?@?[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*)", RegexOptions.Compiled); + new Regex(@"(?<=[^\w@]|^)(?@?[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*)", RegexOptions.Compiled); private static readonly Regex ChildIdentifierDetectionRegex = new Regex( - @"(?@?[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*(\.[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*)*)", + @"(?<=[^\w@]|^)(?@?[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*(\.[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*)*)", RegexOptions.Compiled);