Java tutorial
//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(" ", " "); if (value.length() <= length) return value; else return value.substring(0, length) + "..."; } }