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 Ledger.Utils, | ||||||
| module Text.Printf, | module Text.Printf, | ||||||
| module Text.Regex, | module Text.Regex, | ||||||
|  | module Text.RegexPR, | ||||||
| module Test.HUnit, | module Test.HUnit, | ||||||
| module Ledger.Dates, | module Ledger.Dates, | ||||||
| ) | ) | ||||||
| @ -36,6 +37,7 @@ import Test.HUnit | |||||||
| -- import Test.QuickCheck hiding (test, Testable) | -- import Test.QuickCheck hiding (test, Testable) | ||||||
| import Text.Printf | import Text.Printf | ||||||
| import Text.Regex | import Text.Regex | ||||||
|  | import Text.RegexPR | ||||||
| import Text.ParserCombinators.Parsec (parse) | import Text.ParserCombinators.Parsec (parse) | ||||||
| import Ledger.Dates | import Ledger.Dates | ||||||
| 
 | 
 | ||||||
| @ -120,6 +122,14 @@ containsRegex r s = case matchRegex r s of | |||||||
|                       Just _ -> True |                       Just _ -> True | ||||||
|                       otherwise -> False |                       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 | -- lists | ||||||
| 
 | 
 | ||||||
| splitAtElement :: Eq a => a -> [a] -> [[a]] | splitAtElement :: Eq a => a -> [a] -> [[a]] | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ Extra-Tmp-Files: | |||||||
| Cabal-Version:  >= 1.2 | Cabal-Version:  >= 1.2 | ||||||
| 
 | 
 | ||||||
| Executable hledger | 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 |                   old-locale, time, HUnit | ||||||
|   Main-Is:        hledger.hs |   Main-Is:        hledger.hs | ||||||
|   Other-Modules:   |   Other-Modules:   | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user