mirror of
https://github.com/simonmichael/hledger.git
synced 2025-01-06 02:23:46 +03:00
add a regexp utility plus a dependency on regexpr, the sanest regexp library
This commit is contained in:
parent
1ea8c6c9ee
commit
52ab3372b8
@ -18,6 +18,7 @@ module Debug.Trace,
|
||||
module Ledger.Utils,
|
||||
module Text.Printf,
|
||||
module Text.Regex,
|
||||
module Text.RegexPR,
|
||||
module Test.HUnit,
|
||||
module Ledger.Dates,
|
||||
)
|
||||
@ -36,6 +37,7 @@ import Test.HUnit
|
||||
-- import Test.QuickCheck hiding (test, Testable)
|
||||
import Text.Printf
|
||||
import Text.Regex
|
||||
import Text.RegexPR
|
||||
import Text.ParserCombinators.Parsec (parse)
|
||||
import Ledger.Dates
|
||||
|
||||
@ -120,6 +122,14 @@ containsRegex r s = case matchRegex r s of
|
||||
Just _ -> True
|
||||
otherwise -> False
|
||||
|
||||
-- | Replace all occurrences of a regexp in string using the given replacement function
|
||||
gsubRegexPRBy :: String -> (String -> String) -> String -> String
|
||||
gsubRegexPRBy pat f str =
|
||||
case (matchRegexPR pat str) of
|
||||
Just ((match, (before,after)), _) -> before ++ f match ++ gsubRegexPRBy pat f after
|
||||
Nothing -> str
|
||||
|
||||
|
||||
-- lists
|
||||
|
||||
splitAtElement :: Eq a => a -> [a] -> [[a]]
|
||||
|
@ -19,7 +19,7 @@ Extra-Tmp-Files:
|
||||
Cabal-Version: >= 1.2
|
||||
|
||||
Executable hledger
|
||||
Build-Depends: base, containers, haskell98, directory, parsec, regex-compat,
|
||||
Build-Depends: base, containers, haskell98, directory, parsec, regex-compat, regexpr
|
||||
old-locale, time, HUnit
|
||||
Main-Is: hledger.hs
|
||||
Other-Modules:
|
||||
|
Loading…
Reference in New Issue
Block a user