View Javadoc
1   package org.itracker.util;
2   
3   
4   import org.slf4j.Logger;
5   import org.slf4j.LoggerFactory;
6   
7   import java.util.regex.Matcher;
8   import java.util.regex.Pattern;
9   
10  public class HTMLUtilities {
11  
12      private static final Logger logger = LoggerFactory.getLogger(HTMLUtilities.class);
13      private static final Pattern pattern = Pattern.compile("<[\\w/].*?>", Pattern.CASE_INSENSITIVE);
14      public static String removeMarkup(String input) {
15          String output = (input == null ? "" : input);
16          Matcher matcher = pattern.matcher(input);
17          if (matcher != null && !output.equals("")) {
18              output = matcher.replaceAll("");
19          } else {
20              logger.debug("Failed removing markup.  Pattern = " + pattern + "   Output = " + output);
21          }
22          return output;
23      }
24  }