Created
July 31, 2023 12:19
-
-
Save drchaos/1d27e31685f476ce7894daa035f522c3 to your computer and use it in GitHub Desktop.
Glob-like pattern Boyer-Moore
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
-- Эта функция очень похожа на предыдущую. Она находит первое | |
-- вхожение подстроки и возвращает остаток | |
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