hs-re: Easy to use Regex

[ library, mit, unclassified ] [ Propose Tags ]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0
Dependencies array (>=0.5.0.0), base (>=4.7 && <4.8), regex-base (>=0.93.0), regex-posix (>=0.95.0) [details]
License MIT
Author Hiroki Sato
Maintainer m@skahack.com
Uploaded by SKAhack at 2015-02-26T02:24:32Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 909 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-02-26 [all 1 reports]

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