summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Regex.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-18 21:33:38 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-18 21:33:38 +0100
commit31476dd6b8d30c62153ec8f6dabce4509b57516c (patch)
treeb7513e971a8963deca1a1ea06238954da37efdd1 /src/Text/Hakyll/Regex.hs
parent597116a87d795eb26fc92bdd7519556c89c8b11d (diff)
downloadhakyll-31476dd6b8d30c62153ec8f6dabce4509b57516c.tar.gz
Added basic support for metadata sections.
Diffstat (limited to 'src/Text/Hakyll/Regex.hs')
-rw-r--r--src/Text/Hakyll/Regex.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Text/Hakyll/Regex.hs b/src/Text/Hakyll/Regex.hs
index 37bbc7e..9b7177e 100644
--- a/src/Text/Hakyll/Regex.hs
+++ b/src/Text/Hakyll/Regex.hs
@@ -1,8 +1,10 @@
-- | A module that exports a simple regex interface. This code is mostly copied
--- from the regex-compat package at hackage.
+-- from the regex-compat package at hackage. I decided to write this module
+-- because I want to abstract the regex package used.
module Text.Hakyll.Regex
( splitRegex
, substituteRegex
+ , matchesRegex
) where
import Text.Regex.TDFA
@@ -58,9 +60,15 @@ splitRegex :: String -> String -> [String]
splitRegex pattern = filter (not . null)
. splitRegex' (makeRegex pattern)
--- | Substitute a regex. Simplified interface.
+-- | Substitute a regex. Simplified interface. This function performs a global
+-- substitution.
substituteRegex :: String -- ^ Pattern to replace (regex).
-> String -- ^ Replacement string.
-> String -- ^ Input string.
-> String -- ^ Result.
-substituteRegex pattern replacement str = subRegex (makeRegex pattern) str replacement
+substituteRegex pattern replacement string =
+ subRegex (makeRegex pattern) string replacement
+
+-- | Simple regex matching.
+matchesRegex :: String -> String -> Bool
+matchesRegex string pattern = string =~ pattern