update
This commit is contained in:
@@ -4,15 +4,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.jeesite.common.lang;
|
package com.jeesite.common.lang;
|
||||||
|
|
||||||
|
import com.jeesite.common.codec.EncodeUtils;
|
||||||
|
import com.jeesite.common.collect.ListUtils;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.jeesite.common.codec.EncodeUtils;
|
|
||||||
import com.jeesite.common.collect.ListUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
|
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
|
||||||
* @author ThinkGem
|
* @author ThinkGem
|
||||||
@@ -99,14 +99,13 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
*/
|
*/
|
||||||
public static String stripHtml(String html) {
|
public static String stripHtml(String html) {
|
||||||
if (isBlank(html)){
|
if (isBlank(html)){
|
||||||
return "";
|
return EMPTY;
|
||||||
}
|
}
|
||||||
//html.replaceAll("\\&[a-zA-Z]{0,9};", "").replaceAll("<[^>]*>", "");
|
//html.replaceAll("\\&[a-zA-Z]{0,9};", "").replaceAll("<[^>]*>", "");
|
||||||
String regEx = "<.+?>";
|
String regEx = "<.+?>";
|
||||||
Pattern p = Pattern.compile(regEx);
|
Pattern p = Pattern.compile(regEx);
|
||||||
Matcher m = p.matcher(html);
|
Matcher m = p.matcher(html);
|
||||||
String s = m.replaceAll("");
|
return m.replaceAll(EMPTY);
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,8 +114,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String toMobileHtml(String html){
|
public static String toMobileHtml(String html){
|
||||||
if (html == null){
|
if (isBlank(html)){
|
||||||
return "";
|
return EMPTY;
|
||||||
}
|
}
|
||||||
return html.replaceAll("<([a-z]+?)\\s+?.*?>", "<$1>");
|
return html.replaceAll("<([a-z]+?)\\s+?.*?>", "<$1>");
|
||||||
}
|
}
|
||||||
@@ -127,8 +126,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String toHtml(String txt){
|
public static String toHtml(String txt){
|
||||||
if (txt == null){
|
if (isBlank(txt)){
|
||||||
return "";
|
return EMPTY;
|
||||||
}
|
}
|
||||||
return replace(replace(EncodeUtils.encodeHtml(trim(txt)), "\n", "<br/>"), "\t", " ");
|
return replace(replace(EncodeUtils.encodeHtml(trim(txt)), "\n", "<br/>"), "\t", " ");
|
||||||
}
|
}
|
||||||
@@ -140,8 +139,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String abbr(String str, int length) {
|
public static String abbr(String str, int length) {
|
||||||
if (str == null) {
|
if (isBlank(str)){
|
||||||
return "";
|
return EMPTY;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -159,7 +158,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return "";
|
return EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 缩略字符串替换Html正则表达式预编译
|
// 缩略字符串替换Html正则表达式预编译
|
||||||
@@ -172,8 +171,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String htmlAbbr(String param, int length) {
|
public static String htmlAbbr(String param, int length) {
|
||||||
if (param == null) {
|
if (isBlank(param)){
|
||||||
return "";
|
return EMPTY;
|
||||||
}
|
}
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer();
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user