提交 | 用户 | 时间
|
1ac2bc
|
1 |
package cn.stylefeng.guns.gen.core.util; |
懒 |
2 |
|
|
3 |
import cn.hutool.core.util.StrUtil; |
|
4 |
|
|
5 |
/** |
|
6 |
* 字符串拼接工具类 |
|
7 |
* |
|
8 |
* @author fengshuonan |
|
9 |
* @date 2019-05-06-18:46 |
|
10 |
*/ |
|
11 |
public class ConcatUtil { |
|
12 |
|
|
13 |
//默认拼接符号 |
|
14 |
public static final String DEFAULT_CONTRACT_SYMBOL = "CAT"; |
|
15 |
|
|
16 |
/** |
|
17 |
* 获取字符串数组 |
|
18 |
* |
|
19 |
* @param concatString 形式如CATaaCATbbCATcc的字符串,其中CAT为拼接符号 |
|
20 |
* @author fengshuonan |
|
21 |
* @Date 2019-05-06 18:52 |
|
22 |
*/ |
|
23 |
public static String[] getArray(String concatString) { |
|
24 |
return getArray(concatString, DEFAULT_CONTRACT_SYMBOL); |
|
25 |
} |
|
26 |
|
|
27 |
/** |
|
28 |
* 获取字符串数组 |
|
29 |
* |
|
30 |
* @param concatString 形式如CATaaCATbbCATcc的字符串,其中CAT为拼接符号 |
|
31 |
* @param symbol 拼接符号 |
|
32 |
* @author fengshuonan |
|
33 |
* @Date 2019-05-06 18:52 |
|
34 |
*/ |
|
35 |
public static String[] getArray(String concatString, String symbol) { |
|
36 |
if (StrUtil.isEmpty(concatString)) { |
|
37 |
return new String[]{}; |
|
38 |
} else { |
|
39 |
if (concatString.length() <= symbol.length()) { |
|
40 |
return new String[]{}; |
|
41 |
} else { |
|
42 |
concatString = concatString.substring(symbol.length()); |
|
43 |
return concatString.split(symbol); |
|
44 |
} |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
} |