Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.text.SpannableStringBuilder;

public class Main {
    public static CharSequence htmlfrom(CharSequence text) {
        Pattern htmlflag1 = Pattern.compile("<(.*?)>");
        SpannableStringBuilder builder = new SpannableStringBuilder(text);
        Matcher matcher = htmlflag1.matcher(text);
        while (matcher.find()) {
            builder.delete(matcher.start(), matcher.end());
            text = builder;
            matcher = htmlflag1.matcher(text);
        }
        Pattern htmlflag2 = Pattern.compile("&(.*?);");
        matcher = htmlflag2.matcher(text);
        while (matcher.find()) {
            builder.delete(matcher.start(), matcher.end());
            text = builder;
            matcher = htmlflag2.matcher(text);
        }

        return builder.toString();

    }
}