|
|
@@ -284,6 +284,32 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|
284
|
284
|
}
|
|
285
|
285
|
|
|
286
|
286
|
/**
|
|
|
287
|
+ * 在字符串中查找第一个出现的 `open` 和最后一个出现的 `close` 之间的子字符串
|
|
|
288
|
+ *
|
|
|
289
|
+ * @param str 要截取的字符串
|
|
|
290
|
+ * @param open 起始字符串
|
|
|
291
|
+ * @param close 结束字符串
|
|
|
292
|
+ * @return 截取结果
|
|
|
293
|
+ */
|
|
|
294
|
+ public static String substringBetweenLast(final String str, final String open, final String close)
|
|
|
295
|
+ {
|
|
|
296
|
+ if (isEmpty(str) || isEmpty(open) || isEmpty(close))
|
|
|
297
|
+ {
|
|
|
298
|
+ return NULLSTR;
|
|
|
299
|
+ }
|
|
|
300
|
+ final int start = str.indexOf(open);
|
|
|
301
|
+ if (start != INDEX_NOT_FOUND)
|
|
|
302
|
+ {
|
|
|
303
|
+ final int end = str.lastIndexOf(close);
|
|
|
304
|
+ if (end != INDEX_NOT_FOUND)
|
|
|
305
|
+ {
|
|
|
306
|
+ return str.substring(start + open.length(), end);
|
|
|
307
|
+ }
|
|
|
308
|
+ }
|
|
|
309
|
+ return NULLSTR;
|
|
|
310
|
+ }
|
|
|
311
|
+
|
|
|
312
|
+ /**
|
|
287
|
313
|
* 判断是否为空,并且不是空白字符
|
|
288
|
314
|
*
|
|
289
|
315
|
* @param str 要判断的value
|