Created
February 1, 2010 17:40
-
-
Save mcrisc/291847 to your computer and use it in GitHub Desktop.
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
def normalizar(nome) { | |
normalizado = "" | |
nome.toLowerCase().split().each {parte -> | |
if (!(parte =~ /^[e]$|^d[a-z]{1,2}$/)) { | |
parte = parte[0].toUpperCase() + parte.substring(1) | |
} | |
normalizado += parte + " " | |
} | |
normalizado | |
} | |
nomes = """teste da silva | |
TESTADO DOS SANTOS | |
testador de souza | |
carlos silva e couto | |
JOSÉ paulo testador | |
joão""" | |
nomes.eachLine{println normalizar(it)} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment