hs-re

Easy to use Regex

Latest on Hackage:0.1.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

MIT licensed by Hiroki Sato
Maintained by m@skahack.com

Re

Easy to use Regex for Haskell

import Re
import Data.Array ((!))

main :: IO ()
main = do
    putStrLn $ show $ matchCount "abc" "abcde abcde"
    -- 2
    putStrLn $ show $ matchTest "abc" "abcde abcde"
    -- True
    putStrLn $ concatMap (\m -> fst $ fst m ) $ matchAll "a(b.c)" "abbcdeabmcde"
    -- abbcabmc
    putStrLn $ replace "abc" "abcde abcde" ""
    -- de de
    putStrLn $ replace "(b)(c)" "abcd abcd" "--\\1--\\2--"
    -- a--b--c--d a--b--c--d
    putStrLn $ replaceMap "(b)(c)" "abcd abcd" (\ps -> "--" ++ (ps!!1) ++ "--" ++ (ps!!2) ++ "--")
    -- a--b--c--d a--b--c--d
Used by 1 package:
comments powered byDisqus