Created
September 4, 2014 23:11
-
-
Save ryo1kato/5ddeb944eda843d7f052 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- split bstr into 3 parts: before, on, and after first line with match | |
-- | |
fgrep_line pat bstr = | |
if BS.null bstr | |
then (BS.empty, BS.empty, BS.empty) | |
else (head, BS.concat[left, right], rem) | |
where | |
(h, t) = breakOn pat bstr | |
left = BS.tail $ afterLast (pack "\n") h | |
(right, rem) = breakOn (pack "\n") t | |
head = dropLast (BS.length left + 1) h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment