import Data.List
import qualified Text.Parsec.ByteString as PB
import Text.Parsec.Prim
import Text.Parsec.Combinator
import qualified Data.ByteString.Char8 as BS
import Control.Applicative hiding ( ( <|> ) , many )
validChars
:: PB
.Parser
CharvalidChars = alphaNum <|> oneOf "._"
dontCare
:: PB
.Parser
Char dontCare = oneOf "~!@#$%^&*()<>?,."
{--
emailAddress :: PB.Parser String
emailAddress = do
_ <- many dontCare
fi <- alphaNum
se <- validChars
th <- validChars
fo <- validChars
ft <- validChars
restAddr <- many validChars
let addr = fi : se : th : fo : ft : restAddr
char '@'
dom <- many1 alphaNum
rest <- try ( string ".com" <|> string ".org"
<|> string ".edu" ) <|> try ( string ".co.in" )
_ <- many dontCare
return $ addr ++ ( '@': dom ++ rest )
--}
emailAddress
:: PB
.Parser
StringemailAddress = conCatfun <$> ( many dontCare *> alphaNum ) <*> validChars <*>
validChars <*> validChars <*> validChars <*> many alphaNum <*>
( char '@' *> many1 alphaNum ) <*> ( try ( string ".com" <|>
string ".org" <|> string ".edu" ) <|> try ( string ".co.in" )
<* many dontCare ) where
conCatfun a b c d e f dom rest =
( a : b : c : d : e : f ) ++ ( '@' : dom ++ rest )
collectEmail
:: BS
.ByteString
-> StringcollectEmail email = case parse emailAddress "" email of
Right addr -> addr
Left err -> ""
process
:: ( Int , [ String ] ) -> BS
.ByteString
process
( k
, xs
) = ( BS
.pack
"Case " ) `BS
.append`
( BS
.pack
. show $ k
) `BS
.append`
( BS
.pack
": " ) `BS
.append`
( BS
.pack
. show $ k
) `BS.append` ( BS.pack "\n" ) `BS.append` ( BS.pack
aW1wb3J0IERhdGEuTGlzdAppbXBvcnQgcXVhbGlmaWVkIFRleHQuUGFyc2VjLkJ5dGVTdHJpbmcgYXMgUEIKaW1wb3J0IFRleHQuUGFyc2VjLlByaW0KaW1wb3J0IFRleHQuUGFyc2VjLkNoYXIKaW1wb3J0IFRleHQuUGFyc2VjLkNvbWJpbmF0b3IKaW1wb3J0IHF1YWxpZmllZCBEYXRhLkJ5dGVTdHJpbmcuQ2hhcjggYXMgQlMKaW1wb3J0IENvbnRyb2wuQXBwbGljYXRpdmUgaGlkaW5nICggKCA8fD4gKSAsIG1hbnkgKSAKCnZhbGlkQ2hhcnMgOjogUEIuUGFyc2VyIENoYXIKdmFsaWRDaGFycyAgPSBhbHBoYU51bSA8fD4gb25lT2YgIi5fIiAKCmRvbnRDYXJlIDo6IFBCLlBhcnNlciBDaGFyIApkb250Q2FyZSA9IG9uZU9mICJ+IUAjJCVeJiooKTw+PywuIgoKey0tCmVtYWlsQWRkcmVzcyA6OiBQQi5QYXJzZXIgIFN0cmluZwplbWFpbEFkZHJlc3MgPSBkbyAKICAgICAgICAgICAgIF8gPC0gbWFueSBkb250Q2FyZQogICAgICAgICAgICAgZmkgPC0gYWxwaGFOdW0KICAgICAgICAgICAgIHNlIDwtIHZhbGlkQ2hhcnMKICAgICAgICAgICAgIHRoIDwtIHZhbGlkQ2hhcnMKICAgICAgICAgICAgIGZvIDwtIHZhbGlkQ2hhcnMKICAgICAgICAgICAgIGZ0IDwtIHZhbGlkQ2hhcnMKICAgICAgICAgICAgIHJlc3RBZGRyIDwtIG1hbnkgdmFsaWRDaGFycwogICAgICAgICAgICAgbGV0IGFkZHIgPSBmaSA6IHNlIDogdGggOiBmbyA6IGZ0IDogcmVzdEFkZHIgCiAgICAgICAgICAgICBjaGFyICdAJwogICAgICAgICAgICAgZG9tIDwtIG1hbnkxIGFscGhhTnVtIAogICAgICAgICAgICAgcmVzdCA8LSB0cnkgKCBzdHJpbmcgIi5jb20iIDx8PiBzdHJpbmcgIi5vcmciICAKICAgICAgICAgICAgICAgICAgPHw+ICBzdHJpbmcgIi5lZHUiICkgPHw+IHRyeSAoIHN0cmluZyAiLmNvLmluIiApCiAgICAgICAgICAgICBfIDwtIG1hbnkgZG9udENhcmUKICAgICAgICAgICAgIHJldHVybiAkICBhZGRyICsrICggICdAJzogZG9tICsrIHJlc3QgKSAKICAgCi0tfSAKICAgICAgICAgIAplbWFpbEFk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