Uses of regular expression in String.replaceAll()

package net.xngo.tutorial.java.string;
 
/**
 * Show how to use regular expression in String.replaceAll().
 * @author Xuan Ngo
 *
 */
public class ReplaceAllRegex
{
 
  public static void main(String[] args) 
  {
    String s = "";
 
    /*
     * Remove substring that ends with ,???$
     * Show how to escape and use $.
     */
    s = "53 001,88 $";
    s = s.replaceAll(",...\\$$", "\\$");
    System.out.println(s); // Output: 53 001$
 
    /*
     * Replace a substring regardless of its characters' case(Case Insensitive).
     */
    s = "CaSE Insensitive";
    s = s.replaceAll("(?i)case", "Case");
    System.out.println(s); // Output: Case Insensitive
 
    /*
     * Show how to use backreferences, reuse the matched pattern.
     */
    s = "High Medium Low";
    s = s.replaceAll("(High) (Medium) (Low)", "$3 $2 $1");
    System.out.println(s); // Output: Low Medium High
 
    /*
     * Replace all adjacent wildcard(*) with 1 wildcard(*).
     */
    s = "multiple****wild***card*";
    s = s.replaceAll("[\\*\\*]+", "*");
    System.out.println(s); // Output: multiple*wild*card*
 
 
  }
 
}

https://github.com/xuanngo/Tutorial/blob/master/src/net/xngo/tutorial/java/string/ReplaceAllRegex.java

// Separate words by capital letters JAVA: s.replaceAll("((?<=[a-z])[A-Z]|A-Z)", " $1"); PHP: preg_replace('((?<=[a-z])[A-Z]|A-Z)', ' \0', $string);