break (== c) l == breakSubstring (singleton c) lFor example, to tokenise a string, dropping delimiters:
tokenise x y = h : if null t then [] else tokenise x (drop (length x) t) where (h,t) = breakSubstring x yTo skip to the first occurrence of a string:
snd (breakSubstring x y)To take the parts of a string before a delimiter:
fst (breakSubstring x y)Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern.
break (== c) l == breakSubstring (singleton c) lFor example, to tokenise a string, dropping delimiters:
tokenise x y = h : if null t then [] else tokenise x (drop (length x) t) where (h,t) = breakSubstring x yTo skip to the first occurrence of a string:
snd (breakSubstring x y)To take the parts of a string before a delimiter:
fst (breakSubstring x y)Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern.
break (== c) l == breakSubstring (singleton c) land:
findSubstring s l == if null s then Just 0 else case breakSubstring s l of (x,y) | null y -> Nothing | otherwise -> Just (length x)For example, to tokenise a string, dropping delimiters:
tokenise x y = h : if null t then [] else tokenise x (drop (length x) t) where (h,t) = breakSubstring x yTo skip to the first occurence of a string:
snd (breakSubstring x y)To take the parts of a string before a delimiter:
fst (breakSubstring x y)Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern.