Skip to content

Instantly share code, notes, and snippets.

@dorchard
Last active September 17, 2021 10:57
Show Gist options
  • Save dorchard/1b0e39f143b13049577a85966276cd73 to your computer and use it in GitHub Desktop.
Save dorchard/1b0e39f143b13049577a85966276cd73 to your computer and use it in GitHub Desktop.
Scrub e-mail addresses from HTML page
module Main where
import System.Environment (getArgs)
import System.Exit (exitFailure)
import Data.List (intercalate)
-- Scrub automata
scrub :: String -> [String]
scrub [] = []
scrub ('m':'a':'i':'l':'t':'o':':':rest) =
email : scrub rest'
where
(email, rest') = break (== '\"') rest
scrub (x:xs) = scrub xs
main :: IO ()
main = do
args <- getArgs
case args of
[] -> do
putStrLn "Please specify file to scrub."
exitFailure
(file:_) -> do
fileData <- readFile file
putStrLn (intercalate "," (scrub fileData))
@dorchard
Copy link
Author

Build with ghc scrub.hs -o scrub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment