provide some regex-posix-based utilities that perform better than regexpr

This commit is contained in:
Simon Michael 2013-03-29 18:39:57 +00:00
parent b780badd07
commit 3b5c0bc4a1
2 changed files with 10 additions and 0 deletions

View File

@ -42,6 +42,7 @@ import System.FilePath((</>), isRelative)
import Test.HUnit
import Text.ParserCombinators.Parsec
import Text.Printf
import Text.Regex
import Text.RegexPR
-- import qualified Data.Map as Map
--
@ -202,6 +203,7 @@ difforzero :: (Num a, Ord a) => a -> a -> a
difforzero a b = maximum [(a - b), 0]
-- regexps
-- Note many of these will die on malformed regexps.
-- regexMatch :: String -> String -> MatchFun Maybe
regexMatch r s = matchRegexPR r s
@ -232,6 +234,13 @@ regexToCaseInsensitive r = "(?i)"++ r
regexSplit :: String -> String -> [String]
regexSplit = splitRegexPR
-- regex-compat (regex-posix) functions that perform better than regexpr.
regexMatchesRegexCompat :: String -> String -> Bool
regexMatchesRegexCompat r = isJust . matchRegex (mkRegex r)
regexMatchesCIRegexCompat :: String -> String -> Bool
regexMatchesCIRegexCompat r = isJust . matchRegex (mkRegexWithOpts r True False)
-- lists
splitAtElement :: Eq a => a -> [a] -> [[a]]

View File

@ -66,6 +66,7 @@ library
,old-locale
,old-time
,parsec
,regex-compat == 0.95.*
,regexpr >= 0.5.1
,safe >= 0.2
,split >= 0.1 && < 0.3