Java tutorial
//package com.java2s; import java.util.regex.Pattern; public class Main { public static Pattern removeLeftAngleBracket = Pattern.compile("<"); public static Pattern removeRightAngleBracket = Pattern.compile(">"); public static Pattern removeAmpersand = Pattern.compile("&"); public static String quickTagContentEscape(String aString) { if (aString.indexOf('&') >= 0) { aString = removeAmpersand.matcher(aString).replaceAll("&"); } return escapeAngleBrackets(aString); } public static String escapeAngleBrackets(String aString) { if (aString.indexOf('<') >= 0) { aString = removeLeftAngleBracket.matcher(aString).replaceAll("<"); } if (aString.indexOf('>') >= 0) { aString = removeRightAngleBracket.matcher(aString).replaceAll(">"); } return aString; } }