The hs-re package

[Tags:library, mit]

https:github.comSKAhackhs-re


[Skip to Readme]

Properties

Versions 0.1.0
Dependencies array (>=0.5.0.0), base (==4.7.*), regex-base (>=0.93.0), regex-posix (>=0.95.0) [details]
License MIT
Author Hiroki Sato
Maintainer m@skahack.com
Uploaded Thu Feb 26 02:24:32 UTC 2015 by SKAhack
Distributions NixOS:0.1.0
Downloads 197 total (6 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2015-02-26 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for hs-re

Readme for hs-re-0.1.0

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