@@ -115,6 +115,7 @@ module Data.Text
115115 , splitAt
116116 , spanBy
117117 , break
118+ , breakEnd
118119 , breakBy
119120 , group
120121 , groupBy
@@ -1040,6 +1041,18 @@ break pat src@(Text arr off len)
10401041 (x:_) -> (textP arr off x, textP arr (off+x) (len-x))
10411042{-# INLINE break #-}
10421043
1044+-- | /O(n+m)/ Similar to 'break', but searches from the end of the string.
1045+--
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.
1049+--
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 #-}
1055+
10431056-- | /O(n+m)/ Find all non-overlapping instances of @needle@ in
10441057-- @haystack@. The first element of the returned pair is the prefix
10451058-- of @haystack@ prior to any matches of @needle@. The second is a