Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Created September 1, 2014 14:24
Show Gist options
  • Select an option

  • Save ryo1kato/6b6387ab345855544f25 to your computer and use it in GitHub Desktop.

Select an option

Save ryo1kato/6b6387ab345855544f25 to your computer and use it in GitHub Desktop.
afterLastRegexOf :: ByteStr -> ByteStr -> ByteStr
afterLastRegexOf pat bstr = revSearchRE 0 bstr
where
re = makeRegexOpts compBlank execBlank pat
revSearchRE n s
| BS.null s = bstr
|_
| otherwise = revSearchRE (n+lastlinelen) ()
where
lastline = afterLastRegexOf (pack "\n") s
lastlinelen = BS.length lastline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment