Last active
September 17, 2021 10:57
-
-
Save dorchard/1b0e39f143b13049577a85966276cd73 to your computer and use it in GitHub Desktop.
Scrub e-mail addresses from HTML page
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
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Build with
ghc scrub.hs -o scrub