summaryrefslogtreecommitdiff
path: root/lib/Hakyll/Core
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Hakyll/Core')
-rw-r--r--lib/Hakyll/Core/Identifier/Pattern.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Hakyll/Core/Identifier/Pattern.hs b/lib/Hakyll/Core/Identifier/Pattern.hs
index 47ad21b..83d5adc 100644
--- a/lib/Hakyll/Core/Identifier/Pattern.hs
+++ b/lib/Hakyll/Core/Identifier/Pattern.hs
@@ -27,7 +27,7 @@
-- * @\"foo\/*.html\"@ will match all HTML files in the @\"foo\/\"@ directory.
--
-- The 'capture' function allows the user to get access to the elements captured
--- by the capture elements in the pattern.
+-- by the capture elements in a glob or regex pattern.
module Hakyll.Core.Identifier.Pattern
( -- * The pattern type
Pattern
@@ -260,9 +260,11 @@ splits = inits &&& tails >>> uncurry zip >>> reverse
--------------------------------------------------------------------------------
--- | Match a glob against a pattern, generating a list of captures
+-- | Match a glob or regex pattern against an identifier, generating a list of captures
capture :: Pattern -> Identifier -> Maybe [String]
capture (Glob p) i = capture' p (toFilePath i)
+capture (Regex pat) i = Just groups
+ where (_, _, _, groups) = ((toFilePath i) =~ pat) :: (String, String, String, [String])
capture _ _ = Nothing