The hs-re package

[ Tags: library, mit, unclassified ] [ Propose Tags ]

https://github.com/SKAhack/hs-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 223 total (2 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-02-26 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for hs-re-0.1.0

[back to package description]

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