/** * 截取两字符之间的字符串,str 和 start不能为null或"" */ public static String getCutOutString(String str, String start, String endwith) { if (TextUtils.isEmpty(str)) { return ""; } String result = ""; if (str.contains(start)) { String s1 = str.split(start)[1]; if (endwith == null || "".equals(endwith)) { result = s1; } else { String s2[] = s1.split(endwith); if (s2 != null) { result = s2[0]; } } } return result; }
截取两个String字符串中间的字符串
截取指定字符间的字符串
最新推荐文章于 2024-06-03 16:06:32 发布
本文介绍了一种从字符串中截取两个特定字符之间的子串的方法。该方法使用了简单的字符串操作来实现这一功能,包括判断字符串是否包含起始字符、使用split方法进行分割等。
556

被折叠的 条评论
为什么被折叠?



