Skip to content

Instantly share code, notes, and snippets.

@abuiles
Created February 17, 2010 03:37
Show Gist options
  • Select an option

  • Save abuiles/306258 to your computer and use it in GitHub Desktop.

Select an option

Save abuiles/306258 to your computer and use it in GitHub Desktop.
import Text.Regex.Posix
matcher :: String -> [[String]]
matcher s = s =~ "([A-Za-záéíóúÑñ]+ ?[A-Za-záéíóúÑñ]+? ?[A-Za-záéíóúÑñ]+? ?[A-Za-záéíóúÑñ]+?)\t[0-9]+\t(.*)"
loop :: [String] -> [String]
loop [] = []
loop (x:xs) = let result = matcher x
in case result of
[] -> loop xs
[r] ->("Ciudad: " ++ r !! 2 ++ " Departamento: "++ r !! 1) : loop xs
runregexp = liftM ( unlines . loop . lines ) (readFile "/home/abuiles/linkProg/java/ciudades.txt") >>= writeFile "salida.txt" >> print "Successfully saved"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment