static public String munge(final String s){
  return s.replaceAll("[\\W]","_");
}

static public String munge ( final String s ) { return s . replaceAll ( "[\\W]" , "_" ) ; }
munge a name index so that it is suitable for use in a filesystem . in particular , any non - word characters are converted to an underscore character ( " _ " ) . this gets rid of all punctuation characters and whitespace in the index name itself , but will not translate unicode characters .
