@@ -115,6 +115,7 @@ module Data.Text
115 , splitAt
115 , splitAt
118 , breakBy
119 , breakBy
120 , groupBy
121 , groupBy
@@ -1040,6 +1041,18 @@ break pat src@(Text arr off len)
1040 (x:_) -> (textP arr off x, textP arr (off+x) (len-x))
1041 (x:_) -> (textP arr off x, textP arr (off+x) (len-x))
1041{-# INLINE break #-}
1042{-# INLINE break #-}
1044+-- | /O(n+m)/ Similar to 'break', but searches from the end of the string.
1046+-- The first element of the returned tuple is the prefix of @haystack@
1047+-- up to and including the last match of @needle@. The second is the
1048+-- remainder of @haystack@, following the match.
1050+-- > breakEnd "::" "a::b::c" ==> ("a::b::", "c")
1051+breakEnd :: Text -> Text -> (Text, Text)
1052+breakEnd pat src = let (a,b) = break (reverse pat) (reverse src)
1053+ in (reverse b, reverse a)
1054+{-# INLINE breakEnd #-}
1043-- | /O(n+m)/ Find all non-overlapping instances of @needle@ in
1056-- | /O(n+m)/ Find all non-overlapping instances of @needle@ in
1044-- @haystack@. The first element of the returned pair is the prefix
1057-- @haystack@. The first element of the returned pair is the prefix
1045-- of @haystack@ prior to any matches of @needle@. The second is a
1058-- of @haystack@ prior to any matches of @needle@. The second is a