Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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("&amp;");
        }
        return escapeAngleBrackets(aString);
    }

    public static String escapeAngleBrackets(String aString) {
        if (aString.indexOf('<') >= 0) {
            aString = removeLeftAngleBracket.matcher(aString).replaceAll("&lt;");
        }
        if (aString.indexOf('>') >= 0) {
            aString = removeRightAngleBracket.matcher(aString).replaceAll("&gt;");
        }
        return aString;
    }
}