Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Pattern;

public class Main {
    private static final Pattern invalidXml11 = Pattern
            .compile("[^\u0001-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF]");

    public static String sanitizeXml11(CharSequence sequence) {
        if (sequence == null) {
            return null;
        }
        if (sequence.length() == 0) {
            return "";
        }
        return invalidXml11.matcher(sequence).replaceAll("\uFFFD");
    }

    public static String sanitizeXml11(char[] sequence, int offset, int length) {
        return sanitizeXml11(new String(sequence, offset, length));
    }
}