diff --git a/Ledger/RawLedger.hs b/Ledger/RawLedger.hs index aadb23f74..d64071ca3 100644 --- a/Ledger/RawLedger.hs +++ b/Ledger/RawLedger.hs @@ -182,8 +182,7 @@ matchpats pats str = where (negatives,positives) = partition isnegativepat pats match "" = True - match pat = matchregex (abspat pat) str + match pat = containsRegex (abspat pat) str negateprefix = "not:" isnegativepat pat = negateprefix `isPrefixOf` pat abspat pat = if isnegativepat pat then drop (length negateprefix) pat else pat - matchregex pat str = null pat || containsRegex (mkRegexWithOpts pat True False) str diff --git a/Ledger/Utils.hs b/Ledger/Utils.hs index 18b7a654e..8a335097e 100644 --- a/Ledger/Utils.hs +++ b/Ledger/Utils.hs @@ -19,7 +19,7 @@ module Data.Time.LocalTime, module Debug.Trace, module Ledger.Utils, module Text.Printf, -module Text.Regex, +module Text.RegexPR, module Test.HUnit, ) where @@ -39,7 +39,7 @@ import Debug.Trace import System.IO.UTF8 import Test.HUnit import Text.Printf -import Text.Regex +import Text.RegexPR import Text.ParserCombinators.Parsec @@ -147,10 +147,8 @@ difforzero a b = maximum [(a - b), 0] -- regexps -instance Show Regex where show r = "a Regex" - -containsRegex :: Regex -> String -> Bool -containsRegex r s = case matchRegex r s of +containsRegex :: String -> String -> Bool +containsRegex r s = case matchRegexPR ("(?i)"++r) s of Just _ -> True otherwise -> False @@ -215,7 +213,7 @@ treeany f t = (f $ root t) || (any (treeany f) $ branches t) -- | show a compact ascii representation of a tree showtree :: Show a => Tree a -> String -showtree = unlines . filter (containsRegex (mkRegex "[^ |]")) . lines . drawTree . treemap show +showtree = unlines . filter (containsRegex "[^ |]") . lines . drawTree . treemap show -- | show a compact ascii representation of a forest showforest :: Show a => Forest a -> String diff --git a/Options.hs b/Options.hs index 1ed352dd1..e473e2ae3 100644 --- a/Options.hs +++ b/Options.hs @@ -9,7 +9,6 @@ import System import System.Console.GetOpt import System.Environment import Text.Printf -import Text.RegexPR (gsubRegexPRBy) import Data.Char (toLower) import Ledger.IO (IOArgs, ledgerenvvar,myLedgerPath, diff --git a/hledger.cabal b/hledger.cabal index 9b0e9c624..6b7b24ad7 100644 --- a/hledger.cabal +++ b/hledger.cabal @@ -109,7 +109,6 @@ executable hledger ,mtl ,parsec ,process - ,regex-compat ,regexpr >= 0.5.1 ,split ,testpack