Tuesday, November 1, 2016

regular expression remove font-size

recent I made regular expression for removing font-size tag in style attribute

this is what I made

        private static String removeFontSizeFromStyle(String styleContent) {
  String fontPattern = "[fF][oO][nN][tT]-[sS][iI][zZ][eE]\\s*:\\s*[0-9.]+[a-zA-Z%]*\\s*+;?";

  return styleContent.replaceAll(fontPattern, "");
 }