diff --git a/Ledger/Utils.hs b/Ledger/Utils.hs index 7d15f47b5..8871720bf 100644 --- a/Ledger/Utils.hs +++ b/Ledger/Utils.hs @@ -35,6 +35,24 @@ import Data.Time.Clock (UTCTime, diffUTCTime) import Data.Time.Format (ParseTime, parseTime, formatTime) +-- regexps + +instance Show Regex where show r = "a Regex" + +-- | convert a list of strings to a regular expression matching any of them, +-- or a wildcard if there are none. +regexFor :: [String] -> Regex +regexFor [] = wildcard +regexFor ss = mkRegex $ concat $ ["("] ++ (intersperse "|" ss) ++ [")"] + +wildcard :: Regex +wildcard = mkRegex ".*" + +containsRegex :: Regex -> String -> Bool +containsRegex r s = case matchRegex r s of + Just _ -> True + otherwise -> False + -- time -- | Parse a date-time string to a time type, or raise an error. @@ -66,7 +84,6 @@ splitAtElement e l = -- trees --- aliases root = rootLabel branches = subForest diff --git a/Options.hs b/Options.hs index 981e676ee..6a1ea84d7 100644 --- a/Options.hs +++ b/Options.hs @@ -6,9 +6,6 @@ ledgerFilePathFromOpts, beginDateFromOpts, endDateFromOpts, parseAccountDescriptionArgs, -regexFor, -nullpats, -wildcard, ) where import System @@ -113,17 +110,6 @@ parseAccountDescriptionArgs args = (as, ds') where (as, ds) = break (=="--") args ds' = dropWhile (=="--") ds --- | convert a list of strings to a regular expression matching any of them, --- or a wildcard if there are none. -regexFor :: [String] -> Regex -regexFor [] = wildcard -regexFor ss = mkRegex $ concat $ ["("] ++ (intersperse "|" ss) ++ [")"] - -wildcard :: Regex -wildcard = mkRegex ".*" - -nullpats = (wildcard,wildcard) - -- testoptions RequireOrder ["foo","-v"] -- testoptions Permute ["foo","-v"] -- testoptions (ReturnInOrder Arg) ["foo","-v"]