Remove non-letters from a string

From CodeCodex

Revision as of 18:14, 21 December 2006 by 193.48.163.6 (Talk)

Related content:

Implementations

Java

This code removes common symbols and numbers from a string, returning letters only. (Note, not all symbols are included.)

static String lettersOnly(String s) {
   return s.replaceAll("[0-9]|[ !@#\\$%\\^&\\*\\(\\)_\\+\\-={}\\|:\"<>\\?\\-=\\[\\];',\\./`~'£€¥]","");
}

Tcl

proc remove_non_ascii_letters s {regsub -all {[^a-zA-Z]} $s ""}
remove_non_ascii_letters "hello world! how are you? 0é" ;# -> helloworldhowareyou