Java tutorial
//package com.java2s; public class Main { public static String sanitizeUserInput(String usrInput) { String lower = usrInput.toLowerCase(); if (lower.replaceAll("[^a-z]", "").isEmpty()) { return ""; } String alphabetic = lower.replaceAll("[^a-z ]", ""); return alphabetic.replaceAll("[ ]", "+"); } }