Java String replace all words
public class Main { public static void main(String[] args) { String firstString = "This sentence ends in 5 stars *****"; //www .j av a2s . co m System.out.printf("Original String 1: %s\n", firstString); // replace words with 'word' System.out.printf("Every word replaced by \"word\": %s\n\n", firstString.replaceAll("\\w+", "____")); } }