Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppazos/d46d7586ce382a7cb4669100da28cec0 to your computer and use it in GitHub Desktop.
Save ppazos/d46d7586ce382a7cb4669100da28cec0 to your computer and use it in GitHub Desktop.
Replaces all characters that are not letters or numbers with an underscore
def inputs = [
'hola',
'hola Carola',
'~a`b!c@d#e$f%g@#$%^&^h&i*j(k)l_m+n=o-p'
]
inputs.each {
println it.replaceAll(/[^a-zA-Z0-9]+/,'_')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment