title: Java replace a string with certain characters to hide the string?
body: <p>Ok so I want to replace a string which is returned by a user with specific input. I want to replace every lower case letter, but not spaces!, in the string with a '?'. The place where the inserted '?' should go is in the print statement with the random space (" ") at the end. Thanks for the help. </p>
  
  <pre><code>import java.util.Scanner;
  public class Program05 {
  
      public static void main(String[] args) 
  
      {
      Scanner scanner01 = new Scanner(System.in);
      String inputPhrase; 
  
  
          do {
              System.out.print("Enter a common phrase to begin!: ");
              inputPhrase = scanner01.nextLine(); 
  
          }  while (!inputPhrase.matches("[a-z ]+"));
  
          System.out.print("Press [ENTER] to continue...");  
              try  
              {  
                System.in.read();  
                System.in.skip(System.in.available()); 
              } catch(Exception e){e.printStackTrace();} //though that was a neat little touch 
  
  
           do {
  
              boolean valid = true;
  
  
              for (int i = 0; i &lt; inputPhrase.length(); i++)
                  {
  
                   System.out.println("Common Phrase\n-------------" + "\n" + " " );  
  
  
                      }
  
  
  
  
  
  
              //System.out.print(inputPhrase);
  
  
  
           } while (!inputPhrase.matches("[a-z ]+"));
  
      }
  
  }
  </code></pre>