Python 官方文档:入门教程 => 点击学习
Java去掉指定字符串的开头的指定字符 public static String StringStartTrim(String stream, String
public static String StringStartTrim(String stream, String trim) {
// null或者空字符串的时候不处理
if (stream == null || stream.length() == 0 || trim == null || trim.length() == 0) {
return stream;
}
// 要删除的字符串结束位置
int end;
// 正规表达式
String regPattern = "[" + trim + "]*+";
Pattern pattern = Pattern.compile(regPattern, Pattern.CASE_INSENSITIVE);
// 去掉原始字符串开头位置的指定字符
Matcher matcher = pattern.matcher(stream);
if (matcher.lookingAt()) {
end = matcher.end();
stream = stream.substring(end);
}
// 返回处理后的字符串
return stream;
}
public static String truncateHeadString(String origin, int count) {
if (origin == null || origin.length() < count) {
return null;
}
char[] arr = origin.toCharArray();
char[] ret = new char[arr.length - count];
for (int i = 0; i < ret.length; i++) {
ret[i] = arr[i + count];
}
return String.copyValueOf(ret);
}
origin
:要操作的字符串count
:去掉字符串的数量以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: Java如何去掉指定字符串的开头的指定字符
本文链接: https://www.lsjlt.com/news/135143.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0