regex-do-1.1: PCRE regex funs

Safe HaskellNone
LanguageHaskell2010

Regexdo.Search

Description

from stringsearch package

this module uses newtypes for args plus function names are tweaked

regex is treated as ordinary String. Do not use regex.

Synopsis

Documentation

break :: Needle ByteString -> Haystack ByteString -> (ByteString, ByteString) Source

(front, end) : drop needle

>>> break (Needle ":") (Haystack "0123:oid:90")

("0123", "oid:90")

>>> break (Needle "\n") (Haystack "a\nbc\nde")

("a", "bc\nde")

breakFront :: Needle ByteString -> Haystack ByteString -> (ByteString, ByteString) Source

(front, needle + end)

>>> breakFront (Needle "\n") (Haystack "a\nbc\nde")

("a", "\nbc\nde")

breakEnd :: Needle ByteString -> Haystack ByteString -> (ByteString, ByteString) Source

(front + needle, end)

>>> breakEnd (Needle "\n") (Haystack "a\nbc\nde")

("a\n", "bc\nde")

replace :: Needle ByteString -> Replacement ByteString -> Haystack ByteString -> ByteString Source

>>> replace (Needle "\n") (Replacement ",") (Haystack "a\nbc\nde")

"a,bc,de"

split :: Needle ByteString -> Haystack ByteString -> [ByteString] Source

>>> split (Needle "\n") (Haystack "a\nbc\nde")

["a", "bc", "de"]

>>> split (Needle " ") (Haystack "a bc de")

["a", "bc", "de"]

>>> split (Needle "\\s") (Haystack "abc de fghi ")

["abc de fghi "]

splitEnd :: Needle ByteString -> Haystack ByteString -> [ByteString] Source

>>> splitEnd (Needle "\n") (Haystack "a\nbc\nde")

["a\n", "bc\n", "de"]

splitFront :: Needle ByteString -> Haystack ByteString -> [ByteString] Source

>>> splitFront (Needle "\n") (Haystack "a\nbc\nde")

["a", "\nbc", "\nde"]