More regular expressions for replaceAll( for digits ,alphabets,white spaces or just tabs)

Replaces any numbers with x

    System.out.println("abCdeFGH123456789".replaceAll("[0-9]", "X"));
Code to o replace any numbers with x
    System.out.println("abCdeFGH123456789".replaceAll("\\d", "X"));
  Code to replace anything other than digits
   System.out.println("abCdeFGH123456789".replaceAll("\\D", "X"));

We knoe what trim method on Strings is used to remove white spaces from beginning and end of String

\s removes whitespaces from within the String

      String whiteSpace = "I have spaces and\ttabs in this line before going to new line\n";
      System.out.println(whiteSpace.replaceAll("\\s", "-"));

\t replaces just the tab and not all white spaces like new line \n etc*/

    System.out.println(whiteSpace.replaceAll("\\t", "-"));

w replaces all alphabets from a-z lower case and upper case , all numbers from 0-9 and underscore_

  System.out.println(whiteSpace.replaceAll("\\w", "X"));

b surround all alphabets from a-z and all numbers from 0-9 and underscore_ with X i.e put a X in the beginning and at end of each alphabet and/or letter

   System.out.println(whiteSpace.replaceAll("\\b", "X"));