break package:bytestring

Similar to break, returns the longest (possibly empty) prefix of elements which do not satisfy the predicate and the remainder of the string. break p is equivalent to span (not . p) and to (takeWhile (not . p) &&& dropWhile (not . p)). Under GHC, a rewrite rule will transform break (==) into a call to the specialised breakByte:
break ((==) x) = breakByte x
break (==x) = breakByte x
break p is equivalent to span (not . p).
Similar to break, returns the longest (possibly empty) prefix of elements which do not satisfy the predicate and the remainder of the string. break p is equivalent to span (not . p) and to (takeWhile (not . p) &&& dropWhile (not . p)).
Similar to break, returns the longest (possibly empty) prefix of elements which do not satisfy the predicate and the remainder of the string. break p is equivalent to span (not . p) and to (takeWhile (not . p) &&& dropWhile (not . p)).
Returns the longest (possibly empty) suffix of elements which do not satisfy the predicate and the remainder of the string. breakEnd p is equivalent to spanEnd (not . p) and to (dropWhileEnd (not . p) &&& takeWhileEnd (not . p)).
Break a string on a substring, returning a pair of the part of the string prior to the match, and the rest of the string. The following relationships hold:
break (== c) l == breakSubstring (singleton c) l
For example, to tokenise a string, dropping delimiters:
tokenise x y = h : if null t then [] else tokenise x (drop (length x) t)
where (h,t) = breakSubstring x y
To skip to the first occurrence of a string:
snd (breakSubstring x y)
To take the parts of a string before a delimiter:
fst (breakSubstring x y)
Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern.
breakEnd behaves like break but from the end of the ByteString breakEnd p == spanEnd (not.p)
Returns the longest (possibly empty) suffix of elements which do not satisfy the predicate and the remainder of the string. breakEnd p is equivalent to spanEnd (not . p) and to (takeWhileEnd (not . p) &&& dropWhileEnd (not . p)).
Break a string on a substring, returning a pair of the part of the string prior to the match, and the rest of the string. The following relationships hold:
break (== c) l == breakSubstring (singleton c) l
For example, to tokenise a string, dropping delimiters:
tokenise x y = h : if null t then [] else tokenise x (drop (length x) t)
where (h,t) = breakSubstring x y
To skip to the first occurrence of a string:
snd (breakSubstring x y)
To take the parts of a string before a delimiter:
fst (breakSubstring x y)
Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern.