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;

public class Main {
    public static String subStr(String value, Integer length) {
        if (value == null)
            return null;

        String regEx = "<.+?>";
        Pattern pattern = Pattern.compile(regEx);
        Matcher matcher = pattern.matcher(value);
        value = matcher.replaceAll("");

        value = value.replace("&nbsp;", " ");
        if (value.length() <= length)
            return value;
        else
            return value.substring(0, length) + "...";
    }
}