Skip to content

Instantly share code, notes, and snippets.

@drchaos
Created July 31, 2023 12:19
Show Gist options
  • Save drchaos/1d27e31685f476ce7894daa035f522c3 to your computer and use it in GitHub Desktop.
Save drchaos/1d27e31685f476ce7894daa035f522c3 to your computer and use it in GitHub Desktop.
Glob-like pattern Boyer-Moore
-- Эта функция очень похожа на предыдущую. Она находит первое
-- вхожение подстроки и возвращает остаток
strip :: ByteString -> ByteString -> Maybe ByteString
strip pat
| null pat = Just
strip pat = breaker
where
!patLen = length pat
searcher = nonOverlappingIndices pat
breaker str = case searcher str of
[] -> Nothing
(i:_) -> Just $ snd $ splitAt (i + patLen) str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment