fork download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. /* Name of the class has to be "Main" only if the class is public. */
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. final String regex = "<!DOCTYPE[^>\\[]*(\\[[^\\]]*\\])?>";
  10. final String string = "<!DOCTYPE html><html></html>";
  11. final String subst = "";
  12.  
  13. final Pattern pattern = Pattern.compile(regex);
  14. final Matcher matcher = pattern.matcher(string);
  15.  
  16. // The substituted value will be contained in the result variable
  17. final String result = matcher.replaceAll(subst);
  18.  
  19. System.out.println("Substitution result: " + result);
  20. }
  21. }
Success #stdin #stdout 0.06s 3359744KB
stdin
Standard input is empty
stdout
Substitution result: <html></html>