Skip to content

Instantly share code, notes, and snippets.

@dustinlacewell
Created September 10, 2021 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinlacewell/06a6cb6e97c9fa70bc0342c36fe1374c to your computer and use it in GitHub Desktop.
Save dustinlacewell/06a6cb6e97c9fa70bc0342c36fe1374c to your computer and use it in GitHub Desktop.
notThe :: String -> Maybe String
notThe s =
let p = mkRegex "^[tT][hH][eE]$"
in case matchRegex p s of
Nothing -> Just s
Just o -> Nothing
replaceThe :: String -> String
replaceThe s =
unwords $ Prelude.map (fromMaybe "a" . notThe) (words s)
main :: IO ()
main = do
print $ replaceThe "the robin landed on the branch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment