@@ -27,7 +27,7 @@
27-- * @\"foo\/*.html\"@ will match all HTML files in the @\"foo\/\"@ directory.
27-- * @\"foo\/*.html\"@ will match all HTML files in the @\"foo\/\"@ directory.
29-- The 'capture' function allows the user to get access to the elements captured
29-- The 'capture' function allows the user to get access to the elements captured
30−-- by the capture elements in the pattern.
30+-- by the capture elements in a glob or regex pattern.
31module Hakyll.Core.Identifier.Pattern
31module Hakyll.Core.Identifier.Pattern
32 ( -- * The pattern type
32 ( -- * The pattern type
@@ -260,9 +260,11 @@ splits = inits &&& tails >>> uncurry zip >>> reverse
262--------------------------------------------------------------------------------
262--------------------------------------------------------------------------------
263−-- | Match a glob against a pattern, generating a list of captures
263+-- | Match a glob or regex pattern against an identifier, generating a list of captures
264capture :: Pattern -> Identifier -> Maybe [String]
264capture :: Pattern -> Identifier -> Maybe [String]
265capture (Glob p) i = capture' p (toFilePath i)
265capture (Glob p) i = capture' p (toFilePath i)
266+capture (Regex pat) i = Just groups
267+ where (_, _, _, groups) = ((toFilePath i) =~ pat) :: (String, String, String, [String])
266capture _ _ = Nothing
268capture _ _ = Nothing