Haskell Language Data.Text Checking if a Text is a substring of another Text


Example

ghci> :set -XOverloadedStrings
ghci> import Data.Text as T

isInfixOf :: Text -> Text -> Bool checks whether a Text is contained anywhere within another Text.

ghci> "rum" `T.isInfixOf` "crumble"
True

isPrefixOf :: Text -> Text -> Bool checks whether a Text appears at the beginning of another Text.

ghci> "crumb" `T.isPrefixOf` "crumble"
True

isSuffixOf :: Text -> Text -> Bool checks whether a Text appears at the end of another Text.

ghci> "rumble" `T.isSuffixOf` "crumble"
True