make patterns case-insensitive
This commit is contained in:
parent
ba67e4c0a9
commit
490a81577f
@ -78,18 +78,18 @@ filterRawLedgerEntriesByDate begin end (RawLedger ms ps es f) =
|
|||||||
-- given account name or entry description, applying ledger's special
|
-- given account name or entry description, applying ledger's special
|
||||||
-- cases.
|
-- cases.
|
||||||
--
|
--
|
||||||
-- Patterns are regular expression strings, and those beginning with - are
|
-- Patterns are case-insensitive regular expression strings, and those
|
||||||
-- negative patterns. The special case is that account patterns match the
|
-- beginning with - are negative patterns. The special case is that
|
||||||
-- full account name except in balance reports when the pattern does not
|
-- account patterns match the full account name except in balance reports
|
||||||
-- contain : and is a positive pattern, where it matches only the leaf
|
-- when the pattern does not contain : and is a positive pattern, where it
|
||||||
-- name.
|
-- matches only the leaf name.
|
||||||
matchLedgerPatterns :: Bool -> [String] -> String -> Bool
|
matchLedgerPatterns :: Bool -> [String] -> String -> Bool
|
||||||
matchLedgerPatterns forbalancereport pats str =
|
matchLedgerPatterns forbalancereport pats str =
|
||||||
(null positives || any ismatch positives) && (null negatives || (not $ any ismatch negatives))
|
(null positives || any ismatch positives) && (null negatives || (not $ any ismatch negatives))
|
||||||
where
|
where
|
||||||
isnegative = (== negativepatternchar) . head
|
isnegative = (== negativepatternchar) . head
|
||||||
(negatives,positives) = partition isnegative pats
|
(negatives,positives) = partition isnegative pats
|
||||||
ismatch pat = containsRegex (mkRegex pat') matchee
|
ismatch pat = containsRegex (mkRegexWithOpts pat' True True) matchee
|
||||||
where
|
where
|
||||||
pat' = if isnegative pat then drop 1 pat else pat
|
pat' = if isnegative pat then drop 1 pat else pat
|
||||||
matchee = if forbalancereport && (not $ ':' `elem` pat) && (not $ isnegative pat)
|
matchee = if forbalancereport && (not $ ':' `elem` pat) && (not $ isnegative pat)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user