From 7482f1efc37d8d763f2ea0d7038da00d7032f4e5 Mon Sep 17 00:00:00 2001 From: jneubrand Date: Mon, 30 Jun 2025 23:49:59 +0200 Subject: [PATCH] fix: use precompiled regexes to handle case insensitivity correctly --- hledger-lib/Hledger/Utils/Regex.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hledger-lib/Hledger/Utils/Regex.hs b/hledger-lib/Hledger/Utils/Regex.hs index bbb3cdefe..b8fb3581b 100644 --- a/hledger-lib/Hledger/Utils/Regex.hs +++ b/hledger-lib/Hledger/Utils/Regex.hs @@ -78,8 +78,7 @@ import qualified Data.Text as T import Text.Regex.TDFA ( Regex, CompOption(..), defaultCompOpt, defaultExecOpt, makeRegexOptsM, AllMatches(getAllMatches), match, MatchText, - RegexLike(..), RegexMaker(..), RegexOptions(..), RegexContext(..), - (=~) + RegexLike(..), RegexMaker(..), RegexOptions(..), RegexContext(..) ) @@ -179,8 +178,8 @@ regexMatchText r = matchTest r . T.unpack -- Regex to a Text. regexMatchTextGroups :: Regexp -> Text -> [Text] regexMatchTextGroups r txt = let - pat = reString r - (_,_,_,matches) = txt =~ pat :: (Text,Text,Text,[Text]) + pat = reCompiled r + (_,_,_,matches) = match pat txt :: (Text,Text,Text,[Text]) in matches --------------------------------------------------------------------------------