记得上下班打卡 | git大法好,push需谨慎

Commit 7fe9b9d3 authored by 胡佳晨's avatar 胡佳晨

生成取货码

parent 357923cb
...@@ -69,11 +69,27 @@ public class IDGenerator { ...@@ -69,11 +69,27 @@ public class IDGenerator {
} }
public static String storeRefundCode(String orderMasterCode) { public static String storeRefundCode(String orderMasterCode) {
return orderMasterCode.concat("R").concat(RandomUtil.getRandomInt(0, 50) + ""); return orderMasterCode.concat("R").concat(RandomUtil.getRandomInt(0, 99) + "");
} }
public static String getWriteOffCode() { public static String getWriteOffCode() {
return ""; LocalDateTime now = LocalDateTime.now();
String year = (now.getYear()+"").substring(2);
String day = now.getDayOfYear()+"";
String hour = now.getHour()+"";
String sec = now.getSecond()+"";
String random = RandomUtil.getRandomInt(0,100)+"";
if(day.length()==1){
day="0"+day;
}
if(hour.length()==1){
hour="0"+hour;
}
if(sec.length()==1){
sec="0"+sec;
}
String code = year+day+hour+sec+random;
return StringUtil.switchPosition(StringUtil.switchPosition(code,1,4),3,6);
} }
/** /**
...@@ -123,12 +139,6 @@ public class IDGenerator { ...@@ -123,12 +139,6 @@ public class IDGenerator {
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("" + IDGenerator.payCode()); System.out.println(getWriteOffCode());
System.out.println("" + IDGenerator.refundCode());
System.out.println("nextTimeId===" + IDGenerator.nextTimeId());
System.out.println("nextMilliId===" + IDGenerator.nextMilliId());
System.out.println("nextMilliId2===" + IDGenerator.nextMilliId2());
System.out.println("nextSnowId===" + IDGenerator.nextSnowId());
System.out.println("get32UUID===" + IDGenerator.get32UUID());
} }
} }
...@@ -14,17 +14,25 @@ import java.util.Random; ...@@ -14,17 +14,25 @@ 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 java.util.stream.IntStream; import java.util.stream.IntStream;
/** /**
* 字符串工具类 * 字符串工具类
*
* @author <a href="kowlone2006@163.com">kowlone</a> * @author <a href="kowlone2006@163.com">kowlone</a>
* @version 1.0 2012-4-20 上午2:13:53 * @version 1.0 2012-4-20 上午2:13:53
*/ */
public abstract class StringUtil { public abstract class StringUtil {
/** 随机数对象 */ /**
* 随机数对象
*/
private static final Random random = new Random(); private static final Random random = new Random();
/** 数字与字母字典 */ /**
* 数字与字母字典
*/
private static final char[] LETTER_AND_DIGIT = ("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray(); private static final char[] LETTER_AND_DIGIT = ("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray();
/** 数字与字母字典长度 */ /**
* 数字与字母字典长度
*/
private static final int LETTER_AND_DIGIT_LENGTH = LETTER_AND_DIGIT.length; private static final int LETTER_AND_DIGIT_LENGTH = LETTER_AND_DIGIT.length;
/** 使用Log4j2的消息格式化工厂 */ /** 使用Log4j2的消息格式化工厂 */
...@@ -32,9 +40,9 @@ public abstract class StringUtil { ...@@ -32,9 +40,9 @@ public abstract class StringUtil {
/** /**
* 检测字符串是否为空字符串 * 检测字符串是否为空字符串
* 字符串为空的标准:null或全部由空字符组成的字符串 * 字符串为空的标准:null或全部由空字符组成的字符串
*
* @param str 待检测字符串 * @param str 待检测字符串
* @return * @return <li>true:字符串是空字符串</li>
* <li>true:字符串是空字符串</li>
* <li>false:字符串不是空字符串</li> * <li>false:字符串不是空字符串</li>
*/ */
public static boolean isEmpty(String str) { public static boolean isEmpty(String str) {
...@@ -45,9 +53,9 @@ public abstract class StringUtil { ...@@ -45,9 +53,9 @@ public abstract class StringUtil {
/** /**
* 检测字符串是否为空字符串 * 检测字符串是否为空字符串
* 字符串为空的标准:null或全部由空字符组成的字符串 * 字符串为空的标准:null或全部由空字符组成的字符串
*
* @param obj 待检测字符串 * @param obj 待检测字符串
* @return * @return <li>true:字符串是空字符串</li>
* <li>true:字符串是空字符串</li>
* <li>false:字符串不是空字符串</li> * <li>false:字符串不是空字符串</li>
*/ */
public static boolean isEmpty(Object obj) { public static boolean isEmpty(Object obj) {
...@@ -59,9 +67,9 @@ public abstract class StringUtil { ...@@ -59,9 +67,9 @@ public abstract class StringUtil {
/** /**
* 检测字符串是否不为空字符串 * 检测字符串是否不为空字符串
* 字符串为空的标准:null或全部由空字符组成的字符串 * 字符串为空的标准:null或全部由空字符组成的字符串
*
* @param str 待检测字符串 * @param str 待检测字符串
* @return * @return <li>true:字符串不是空字符串</li>
* <li>true:字符串不是空字符串</li>
* <li>false:字符串是空字符串</li> * <li>false:字符串是空字符串</li>
* @see #isEmpty(String) * @see #isEmpty(String)
*/ */
...@@ -71,6 +79,7 @@ public abstract class StringUtil { ...@@ -71,6 +79,7 @@ public abstract class StringUtil {
/** /**
* 将对象转换为字符串 * 将对象转换为字符串
*
* @param input 待转换对象 * @param input 待转换对象
* @return 转换后的字符串 * @return 转换后的字符串
* @see #getString(Object, String) * @see #getString(Object, String)
...@@ -84,6 +93,7 @@ public abstract class StringUtil { ...@@ -84,6 +93,7 @@ public abstract class StringUtil {
/** /**
* 将对象转换为字符串 * 将对象转换为字符串
*
* @param input 待转换对象 * @param input 待转换对象
* @param defVal 对象转换为空字符串时的默认返回值 * @param defVal 对象转换为空字符串时的默认返回值
* @return 转换后的字符串 * @return 转换后的字符串
...@@ -96,6 +106,7 @@ public abstract class StringUtil { ...@@ -96,6 +106,7 @@ public abstract class StringUtil {
/** /**
* 转换字符串 * 转换字符串
*
* @param input 待转换字符串 * @param input 待转换字符串
* @return 转换后的字符串 * @return 转换后的字符串
* @see #getString(String, String) * @see #getString(String, String)
...@@ -106,6 +117,7 @@ public abstract class StringUtil { ...@@ -106,6 +117,7 @@ public abstract class StringUtil {
/** /**
* 转换字符串 * 转换字符串
*
* @param input 待转换字符串 * @param input 待转换字符串
* @param defVal 默认转换值 * @param defVal 默认转换值
* @return 转换后的字符串 * @return 转换后的字符串
...@@ -118,6 +130,7 @@ public abstract class StringUtil { ...@@ -118,6 +130,7 @@ public abstract class StringUtil {
/** /**
* 生成固定长度的随机字符串 * 生成固定长度的随机字符串
*
* @param len 随机字符串长度 * @param len 随机字符串长度
* @return 生成的随机字符串 * @return 生成的随机字符串
*/ */
...@@ -134,6 +147,7 @@ public abstract class StringUtil { ...@@ -134,6 +147,7 @@ public abstract class StringUtil {
/** /**
* 生成固定长度的随机字符串 * 生成固定长度的随机字符串
*
* @param len 随机字符串长度 * @param len 随机字符串长度
* @param dictionary 字符串字典 * @param dictionary 字符串字典
* @return 生成的随机字符串 * @return 生成的随机字符串
...@@ -151,6 +165,7 @@ public abstract class StringUtil { ...@@ -151,6 +165,7 @@ public abstract class StringUtil {
/** /**
* 创建一个新的字符串 * 创建一个新的字符串
*
* @param bytes 字符串内容字节数组(UTF-8编码) * @param bytes 字符串内容字节数组(UTF-8编码)
* @return 新创建的字符串 * @return 新创建的字符串
* @see #newString(byte[], String) * @see #newString(byte[], String)
...@@ -161,6 +176,7 @@ public abstract class StringUtil { ...@@ -161,6 +176,7 @@ public abstract class StringUtil {
/** /**
* 创建一个新的字符串 * 创建一个新的字符串
*
* @param bytes 字符串内容字节数组 * @param bytes 字符串内容字节数组
* @param charset 字符串字节编码 * @param charset 字符串字节编码
* @return 新创建的字符串 * @return 新创建的字符串
...@@ -175,6 +191,7 @@ public abstract class StringUtil { ...@@ -175,6 +191,7 @@ public abstract class StringUtil {
/** /**
* 取得字符串字节数组 * 取得字符串字节数组
*
* @param str 字符串 * @param str 字符串
* @return 字符串内容字节数组 * @return 字符串内容字节数组
* @see #getBytes(String, String) * @see #getBytes(String, String)
...@@ -185,6 +202,7 @@ public abstract class StringUtil { ...@@ -185,6 +202,7 @@ public abstract class StringUtil {
/** /**
* 取得字符串字节数组 * 取得字符串字节数组
*
* @param str 字符串 * @param str 字符串
* @param charset 字符串字节编码 * @param charset 字符串字节编码
* @return 字符串内容字节数组 * @return 字符串内容字节数组
...@@ -202,21 +220,22 @@ public abstract class StringUtil { ...@@ -202,21 +220,22 @@ public abstract class StringUtil {
/** /**
* 从右侧开始截取固定长度的字符串 * 从右侧开始截取固定长度的字符串
*
* @param str 待截取字符串 * @param str 待截取字符串
* @param length 截取的长度 * @param length 截取的长度
* @return * @return <li>null:字符串为空或字符串长度小于截取的长度</li>
* <li>null:字符串为空或字符串长度小于截取的长度</li>
* <li>非null:截取字符串后的结果</li> * <li>非null:截取字符串后的结果</li>
*/ */
public static String right(String str, int length) { public static String right(String str, int length) {
return (str == null || str.length() < length) ? null : str.substring(str.length() - length); return (str == null || str.length() < length) ? null : str.substring(str.length() - length);
} }
/** /**
* 从左侧开始截取固定长度的字符串 * 从左侧开始截取固定长度的字符串
*
* @param str 待截取字符串 * @param str 待截取字符串
* @param length 截取的长度 * @param length 截取的长度
* @return * @return <li>null:字符串为空或字符串长度小于截取的长度</li>
* <li>null:字符串为空或字符串长度小于截取的长度</li>
* <li>非null:截取字符串后的结果</li> * <li>非null:截取字符串后的结果</li>
*/ */
public static String left(String str, int length) { public static String left(String str, int length) {
...@@ -225,14 +244,15 @@ public abstract class StringUtil { ...@@ -225,14 +244,15 @@ public abstract class StringUtil {
/** /**
* 截取定长字符串(中文、字符、字母、数字……) * 截取定长字符串(中文、字符、字母、数字……)
*
* @param str * @param str
* @param fixedWidth * @param fixedWidth
* @return * @return
*/ */
public static String subFixedWidthString(String str, int fixedWidth) { public static String subFixedWidthString(String str, int fixedWidth) {
if(str.length() <= fixedWidth) { if (str.length() <= fixedWidth) {
return str; return str;
}else{ } else {
StringBuilder ret = new StringBuilder(); StringBuilder ret = new StringBuilder();
fixedWidth = fixedWidth << 1; fixedWidth = fixedWidth << 1;
int currentWidth = 0; int currentWidth = 0;
...@@ -252,6 +272,7 @@ public abstract class StringUtil { ...@@ -252,6 +272,7 @@ public abstract class StringUtil {
/** /**
* 将数组中字符串按照分隔符连接成一个字符串 * 将数组中字符串按照分隔符连接成一个字符串
*
* @param seperator 分隔符 * @param seperator 分隔符
* @param params 待连接字符串数组 * @param params 待连接字符串数组
* @return 连接后的字符串 * @return 连接后的字符串
...@@ -259,8 +280,10 @@ public abstract class StringUtil { ...@@ -259,8 +280,10 @@ public abstract class StringUtil {
public static String join(String seperator, Object... params) { public static String join(String seperator, Object... params) {
return joinArray(seperator, params); return joinArray(seperator, params);
} }
/** /**
* 将数组中字符串按照分隔符连接成一个字符串 * 将数组中字符串按照分隔符连接成一个字符串
*
* @param seperator 分隔符 * @param seperator 分隔符
* @param params 待连接字符串数组 * @param params 待连接字符串数组
* @return 连接后的字符串 * @return 连接后的字符串
...@@ -272,14 +295,14 @@ public abstract class StringUtil { ...@@ -272,14 +295,14 @@ public abstract class StringUtil {
StringBuilder ret = new StringBuilder(); StringBuilder ret = new StringBuilder();
for (Object param : params) { for (Object param : params) {
if(param == null) { if (param == null) {
continue; continue;
} }
if (ret.length() > 0) { if (ret.length() > 0) {
ret.append(seperator); ret.append(seperator);
} }
if (param.getClass().isArray()) { if (param.getClass().isArray()) {
ret.append(joinArray(seperator, (Object[])param)); ret.append(joinArray(seperator, (Object[]) param));
} else { } else {
ret.append(param); ret.append(param);
} }
...@@ -289,10 +312,10 @@ public abstract class StringUtil { ...@@ -289,10 +312,10 @@ public abstract class StringUtil {
/** /**
* 比较两个字符串大小 * 比较两个字符串大小
*
* @param str1 字符串1 * @param str1 字符串1
* @param str2 字符串2 * @param str2 字符串2
* @return * @return <li>-1:str1小</li>
* <li>-1:str1小</li>
* <li>0:两字符串相等</li> * <li>0:两字符串相等</li>
* <li>1:str2小</li> * <li>1:str2小</li>
*/ */
...@@ -328,6 +351,7 @@ public abstract class StringUtil { ...@@ -328,6 +351,7 @@ public abstract class StringUtil {
/** /**
* 根据参数填充占位符,构建字符串消息,例如: * 根据参数填充占位符,构建字符串消息,例如:
* msg=我是{} params:小明 返回值为:我是小明 * msg=我是{} params:小明 返回值为:我是小明
*
* @param message * @param message
* @param params * @param params
* @return * @return
...@@ -342,18 +366,19 @@ public abstract class StringUtil { ...@@ -342,18 +366,19 @@ public abstract class StringUtil {
/** /**
* 过滤空格 * 过滤空格
*
* @param str 待过滤字符串 * @param str 待过滤字符串
* @return 过滤结果 * @return 过滤结果
*/ */
public static String trim (String str) { public static String trim(String str) {
return str == null ? null : str.trim(); return str == null ? null : str.trim();
} }
/** /**
* 将字符串指定索引位的字符转换为大写 * 将字符串指定索引位的字符转换为大写
*
* @param source * @param source
* @param index * @param index
*
* @return * @return
*/ */
public static String toUpperCase(String source, int index) { public static String toUpperCase(String source, int index) {
...@@ -399,7 +424,7 @@ public abstract class StringUtil { ...@@ -399,7 +424,7 @@ public abstract class StringUtil {
} }
public static final boolean isEmail(String str) { public static final boolean isEmail(String str) {
String paString ="^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$"; String paString = "^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$";
Pattern pattern = Pattern.compile(paString); // 验证邮箱 Pattern pattern = Pattern.compile(paString); // 验证邮箱
Matcher matcher = pattern.matcher(str); Matcher matcher = pattern.matcher(str);
boolean b = matcher.matches(); boolean b = matcher.matches();
...@@ -437,8 +462,9 @@ public abstract class StringUtil { ...@@ -437,8 +462,9 @@ public abstract class StringUtil {
return left(idcardNumber, 2) + "****" + idcardNumber.substring(6, 8) + "******" + right(idcardNumber, 4); return left(idcardNumber, 2) + "****" + idcardNumber.substring(6, 8) + "******" + right(idcardNumber, 4);
} }
} }
public static String hiddenBankId(String bankId){
if(isEmpty(bankId)){ public static String hiddenBankId(String bankId) {
if (isEmpty(bankId)) {
return ""; return "";
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -451,9 +477,9 @@ public abstract class StringUtil { ...@@ -451,9 +477,9 @@ public abstract class StringUtil {
public static boolean isBlank(CharSequence cs) { public static boolean isBlank(CharSequence cs) {
int strLen; int strLen;
if(cs != null && (strLen = cs.length()) != 0) { if (cs != null && (strLen = cs.length()) != 0) {
for(int i = 0; i < strLen; ++i) { for (int i = 0; i < strLen; ++i) {
if(!Character.isWhitespace(cs.charAt(i))) { if (!Character.isWhitespace(cs.charAt(i))) {
return false; return false;
} }
} }
...@@ -468,12 +494,12 @@ public abstract class StringUtil { ...@@ -468,12 +494,12 @@ public abstract class StringUtil {
return !isBlank(cs); return !isBlank(cs);
} }
public static String andStartTime(String start){ public static String andStartTime(String start) {
return start+" 00:00:00"; return start + " 00:00:00";
} }
public static String andEndTime(String end){ public static String andEndTime(String end) {
return end+" 23:59:59"; return end + " 23:59:59";
} }
...@@ -491,8 +517,7 @@ public abstract class StringUtil { ...@@ -491,8 +517,7 @@ public abstract class StringUtil {
* @param object Object * @param object Object
* @return true:为空 false:非空 * @return true:为空 false:非空
*/ */
public static boolean isNull(Object object) public static boolean isNull(Object object) {
{
return object == null; return object == null;
} }
...@@ -502,8 +527,7 @@ public abstract class StringUtil { ...@@ -502,8 +527,7 @@ public abstract class StringUtil {
* @param object Object * @param object Object
* @return true:非空 false:空 * @return true:非空 false:空
*/ */
public static boolean isNotNull(Object object) public static boolean isNotNull(Object object) {
{
return !isNull(object); return !isNull(object);
} }
...@@ -511,10 +535,9 @@ public abstract class StringUtil { ...@@ -511,10 +535,9 @@ public abstract class StringUtil {
* * 判断一个对象数组是否为空 * * 判断一个对象数组是否为空
* *
* @param objects 要判断的对象数组 * @param objects 要判断的对象数组
** @return true:为空 false:非空 * * @return true:为空 false:非空
*/ */
public static boolean isEmpty(Object[] objects) public static boolean isEmpty(Object[] objects) {
{
return isNull(objects) || (objects.length == 0); return isNull(objects) || (objects.length == 0);
} }
...@@ -524,8 +547,7 @@ public abstract class StringUtil { ...@@ -524,8 +547,7 @@ public abstract class StringUtil {
* @param objects 要判断的对象数组 * @param objects 要判断的对象数组
* @return true:非空 false:空 * @return true:非空 false:空
*/ */
public static boolean isNotEmpty(Object[] objects) public static boolean isNotEmpty(Object[] objects) {
{
return !isEmpty(objects); return !isEmpty(objects);
} }
...@@ -535,8 +557,7 @@ public abstract class StringUtil { ...@@ -535,8 +557,7 @@ public abstract class StringUtil {
* @param coll 要判断的Collection * @param coll 要判断的Collection
* @return true:为空 false:非空 * @return true:为空 false:非空
*/ */
public static boolean isEmpty(Collection<?> coll) public static boolean isEmpty(Collection<?> coll) {
{
return isNull(coll) || coll.isEmpty(); return isNull(coll) || coll.isEmpty();
} }
...@@ -546,8 +567,7 @@ public abstract class StringUtil { ...@@ -546,8 +567,7 @@ public abstract class StringUtil {
* @param coll 要判断的Collection * @param coll 要判断的Collection
* @return true:非空 false:空 * @return true:非空 false:空
*/ */
public static boolean isNotEmpty(Collection<?> coll) public static boolean isNotEmpty(Collection<?> coll) {
{
return !isEmpty(coll); return !isEmpty(coll);
} }
...@@ -557,8 +577,7 @@ public abstract class StringUtil { ...@@ -557,8 +577,7 @@ public abstract class StringUtil {
* @param map 要判断的Map * @param map 要判断的Map
* @return true:为空 false:非空 * @return true:为空 false:非空
*/ */
public static boolean isEmpty(Map<?, ?> map) public static boolean isEmpty(Map<?, ?> map) {
{
return isNull(map) || map.isEmpty(); return isNull(map) || map.isEmpty();
} }
...@@ -568,8 +587,7 @@ public abstract class StringUtil { ...@@ -568,8 +587,7 @@ public abstract class StringUtil {
* @param map 要判断的Map * @param map 要判断的Map
* @return true:非空 false:空 * @return true:非空 false:空
*/ */
public static boolean isNotEmpty(Map<?, ?> map) public static boolean isNotEmpty(Map<?, ?> map) {
{
return !isEmpty(map); return !isEmpty(map);
} }
...@@ -580,14 +598,10 @@ public abstract class StringUtil { ...@@ -580,14 +598,10 @@ public abstract class StringUtil {
* @param strs 字符串组 * @param strs 字符串组
* @return 包含返回true * @return 包含返回true
*/ */
public static boolean inStringIgnoreCase(String str, String... strs) public static boolean inStringIgnoreCase(String str, String... strs) {
{ if (str != null && strs != null) {
if (str != null && strs != null) for (String s : strs) {
{ if (str.equalsIgnoreCase(trim(s))) {
for (String s : strs)
{
if (str.equalsIgnoreCase(trim(s)))
{
return true; return true;
} }
} }
...@@ -595,10 +609,28 @@ public abstract class StringUtil { ...@@ -595,10 +609,28 @@ public abstract class StringUtil {
return false; return false;
} }
/**
* 字符串位置交换
*
* @param p1 位置1
* @param p2 位置2
* @return 交换位置大于字符长度返回原字符。小于返回交换后结果
*/
public static String switchPosition(String str, int p1, int p2) {
if (str.length() < p1 + 1 || str.length() < p2 + 1) {
return str;
}
char[] charArray = str.toCharArray();
char temp = charArray[p1];
charArray[p1] = charArray[p2];
charArray[p2] = temp;
return String.valueOf(charArray);
}
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(isEmail("123@qq.com#$%^&*()")); System.out.println(isEmail("123@qq.com#$%^&*()"));
String regEx="[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]"; String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
//可以在中括号内加上任何想要替换的字符,实际上是一个正则表达式 //可以在中括号内加上任何想要替换的字符,实际上是一个正则表达式
...@@ -609,7 +641,7 @@ public abstract class StringUtil { ...@@ -609,7 +641,7 @@ public abstract class StringUtil {
Matcher m = p.matcher("原字符串");//这里把想要替换的字符串传进来 Matcher m = p.matcher("原字符串");//这里把想要替换的字符串传进来
String newString = m.replaceAll(aa).trim(); String newString = m.replaceAll(aa).trim();
System.out.println("newString====="+newString); System.out.println("newString=====" + newString);
//将替换后的字符串存在变量newString中 //将替换后的字符串存在变量newString中
...@@ -617,8 +649,8 @@ public abstract class StringUtil { ...@@ -617,8 +649,8 @@ public abstract class StringUtil {
String str = "#$%^&*()我的正确#$%^&*()原字符串#$%^&*()"; String str = "#$%^&*()我的正确#$%^&*()原字符串#$%^&*()";
String newString2 = str.replaceAll(regEx,aa).trim();//不想保留原来的字符串可以直接写成 “str = str.replaceAll(regEX,aa);” String newString2 = str.replaceAll(regEx, aa).trim();//不想保留原来的字符串可以直接写成 “str = str.replaceAll(regEX,aa);”
System.out.println("newString2====="+newString2); System.out.println("newString2=====" + newString2);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment