@@ -80,7 +80,9 @@ public static String[] parseDsv(String dsv, String delimiter, boolean trim) {
80
80
81
81
if (trim ) {
82
82
// Replace all consecutive spaces or delimiter characters with a single delimiter character
83
- dsv = dsv .trim ().replaceAll ("\\ s*" + delimiter + "\\ s*" , delimiter );
83
+ //String regex = "\\s*" + delimiter + "\\s*";
84
+ String regex = "\\ s*+" + delimiter + "\\ s*+" ;
85
+ dsv = dsv .trim ().replaceAll (regex , delimiter );
84
86
}
85
87
// Use StringUtils.split, which does not use regular expressions
86
88
return StringUtils .split (dsv , delimiter );
@@ -97,7 +99,9 @@ public static String[] parsePsv(String psv, boolean trim) {
97
99
}
98
100
if (trim ) {
99
101
// Replace all consecutive spaces or delimiter characters with a single delimiter character
100
- psv = psv .trim ().replaceAll ("[\\ s|]+" , "|" );
102
+ String regex = "[\\ s|]+" ;
103
+ //String regex = "\\s*+|\\s*+";
104
+ psv = psv .trim ().replaceAll (regex , "|" );
101
105
}
102
106
// Use StringUtils.split, which does not use regular expressions
103
107
return StringUtils .split (psv , '|' );
@@ -108,14 +112,14 @@ public static String[] parseCsv(String csv) {
108
112
}
109
113
110
114
public static String [] parseCsv (String csv , boolean trim ) {
111
- //return StringUtils.isBlank(csv) ? EMPTY_STR_ARRAY : csv.trim().split(REGEX_CSV);
112
115
if (StringUtils .isBlank (csv )) {
113
116
return EMPTY_STR_ARRAY ;
114
117
}
115
- //return StringUtils.isBlank(csv) ? EMPTY_STR_ARRAY : StringUtils.split(csv);
116
118
if (trim ) {
117
119
// Replace all consecutive spaces or delimiter characters with a single delimiter character
118
- csv = csv .trim ().replaceAll ("\\ s*,\\ s*" , "," );
120
+ //String regex = "\\s*,\\s*";
121
+ String regex = "\\ s*+,\\ s*+" ;
122
+ csv = csv .trim ().replaceAll (regex , "," );
119
123
}
120
124
// Use StringUtils.split, which does not use regular expressions
121
125
return StringUtils .split (csv , ',' );
@@ -126,13 +130,14 @@ public static String[] parseURL(String url) {
126
130
}
127
131
128
132
public static String [] parseURL (String url , boolean trim ) {
129
- //return StringUtils.isBlank(url) ? EMPTY_STR_ARRAY : url.trim().split(REGEX_URL);
130
133
if (StringUtils .isBlank (url )) {
131
134
return EMPTY_STR_ARRAY ;
132
135
}
133
136
if (trim ) {
134
137
// Replace all consecutive spaces or delimiter characters with a single delimiter character
135
- url = url .trim ().replaceAll ("\\ s*/\\ s*" , "/" );
138
+ //String regex = "\\s*/\\s*";
139
+ String regex = "\\ s*+/\\ s*+" ;
140
+ url = url .trim ().replaceAll (regex , "/" );
136
141
}
137
142
return StringUtils .split (url , '/' );
138
143
}
@@ -295,9 +300,10 @@ public static Map<String, String> parseMap(String mapCVS, boolean trim) {
295
300
Map <String , String > ret = new HashMap <>();
296
301
String [] mapKeyValues = parseCsv (mapCVS , true );
297
302
for (String mapKeyValue : mapKeyValues ) {
298
- //String[] ap = mapKeyValue.trim().split(REGEX_BINDING_MAP);
299
303
if (trim ) {
300
- mapKeyValue = mapKeyValue .trim ().replaceAll ("\\ s*:\\ s*" , ":" );
304
+ //String regex = "\\s*:\\s*";
305
+ String regex = "\\ s*+:\\ s*+" ;
306
+ mapKeyValue = mapKeyValue .trim ().replaceAll (regex , ":" );
301
307
}
302
308
String [] ap = StringUtils .split (mapKeyValue , ':' );
303
309
ret .put (ap [0 ], ap [1 ]);
0 commit comments