span package:bytestring

Similar to span, returns the longest (possibly empty) prefix of elements satisfying the predicate and the remainder of the string. span p is equivalent to break (not . p) and to (takeWhile p &&& dropWhile p).
span p xs breaks the ByteString into two segments. It is equivalent to (takeWhile p xs, dropWhile p xs)
Similar to span, returns the longest (possibly empty) prefix of elements satisfying the predicate and the remainder of the string. span p is equivalent to break (not . p) and to (takeWhile p &&& dropWhile p).
Returns the longest (possibly empty) suffix of elements satisfying the predicate and the remainder of the string. spanEnd p is equivalent to breakEnd (not . p) and to (dropWhileEnd p &&& takeWhileEnd p). We have
spanEnd (not . isSpace) "x y z" == ("x y ", "z")
and
spanEnd (not . isSpace) ps
==
let (x, y) = span (not . isSpace) (reverse ps) in (reverse y, reverse x)
spanEnd behaves like span but from the end of the ByteString. We have
spanEnd (not.isSpace) "x y z" == ("x y ","z")
and
spanEnd (not . isSpace) ps
==
let (x,y) = span (not.isSpace) (reverse ps) in (reverse y, reverse x)
Returns the longest (possibly empty) suffix of elements satisfying the predicate and the remainder of the string. spanEnd p is equivalent to breakEnd (not . p) and to (takeWhileEnd p &&& dropWhileEnd p). We have
spanEnd (not . isSpace) "x y z" == ("x y ", "z")
and
spanEnd (not . isSpace) sbs
==
let (x, y) = span (not . isSpace) (reverse sbs) in (reverse y, reverse x)