Have you ever wanted to do case expr of regexhere -> ... ? You can do almost that with view patterns! {-# LANGUAGE ViewPatterns #-} import Text.Regex.Posix -- Helper pat :: String -> String -> [[String]] pat p s = s =~ p -- Function with matching foo :: String -> String foo (pat "foo(bar|baz)" -> [[_,x]]) = x foo _ = "no!" main :: IO () main = do print $ foo "foobar" print $ foo "foobaz" print $ f
{{#tags}}- {{label}}
{{/tags}}