regex-do-1.4: PCRE wrapper

Safe HaskellNone
LanguageHaskell2010

Text.Regex.Do.Split

Description

see Data.ByteString.Search package

this module uses newtypes for args

regex is treated as ordinary String

Synopsis

Documentation

break :: Pattern ByteString -> Body ByteString -> (ByteString, ByteString) Source

(front, end) : drop needle

>>> break (Pattern ":") (Body "0123:oid:90")

("0123", "oid:90")

>>> break (Pattern "\n") (Body "a\nbc\nde")

("a", "bc\nde")

breakFront :: Pattern ByteString -> Body ByteString -> (ByteString, ByteString) Source

(front, needle + end)

>>> breakFront (Pattern "\n") (Body "a\nbc\nde")

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

breakEnd :: Pattern ByteString -> Body ByteString -> (ByteString, ByteString) Source

(front + needle, end)

>>> breakEnd (Pattern "\n") (Body "a\nbc\nde")

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

replace :: Pattern ByteString -> Replacement ByteString -> Body ByteString -> ByteString Source

>>> replace (Pattern "\n") (Replacement ",") (Body "a\nbc\nde")

"a,bc,de"

split :: Pattern ByteString -> Body ByteString -> [ByteString] Source

>>> split (Pattern "\n") (Body "a\nbc\nde")

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

>>> split (Pattern " ") (Body "a bc de")

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

>>> split (Pattern "\\s") (Body "abc de fghi ")

["abc de fghi "]

splitEnd :: Pattern ByteString -> Body ByteString -> [ByteString] Source

>>> splitEnd (Pattern "\n") (Body "a\nbc\nde")

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

splitFront :: Pattern ByteString -> Body ByteString -> [ByteString] Source

>>> splitFront (Pattern "\n") (Body "a\nbc\nde")

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