public class MainClass
{
public static void main( String args[] )
{
String firstString = "This sentence ends in 5 stars *****";
String secondString = "1, 2, 3, 4, 5, 6, 7, 8";
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+", "word" ) );
System.out.printf( "Original String 2: %s\n", secondString );
}
}
|