module Shaker.Regex(
processListWithRegexp
) where
import Text.Regex.Posix
import Data.List
processListWithRegexp ::
[String]
-> [String]
-> [String]
-> [String]
processListWithRegexp list [] [] = list
processListWithRegexp list fileListenInfoIgnore [] = nub $ list \\ getExcluded list fileListenInfoIgnore
processListWithRegexp list [] fileListenInfoInclude = nub $ getIncluded list fileListenInfoInclude
processListWithRegexp list fileListenInfoIgnore fileListenInfoInclude =
nub $ getIncluded list fileListenInfoInclude \\ getExcluded list fileListenInfoIgnore
getExcluded :: [String] -> [String] -> [String]
getExcluded list patterns = filter funExclude list
where funExclude el = any (\a -> el =~+ (a,compIgnoreCase, execBlank) ) patterns
getIncluded :: [String] -> [String] -> [String]
getIncluded list patterns = filter funInclude list
where funInclude el = any (\a -> el =~+ (a,compIgnoreCase, execBlank) ) patterns
(=~+) :: ( RegexMaker regex compOpt execOpt source, RegexContext regex source1 target ) => source1 -> (source, compOpt, execOpt) -> target
source1 =~+ (source, compOpt, execOpt) = match (makeRegexOpts compOpt execOpt source) source1