多语言展示
当前在线:1207今日阅读:27今日分享:41

java替换指定字符串的指定区间内字符为'*'

替换指定字符串的指定区间内字符为'*'
工具/原料
1

电脑

2

java

3

hutool

方法/步骤
1

在项目中引入hutool的jar包

2

首先定义一个String类型的字符串

3

startInclude 开始位置(包含)endExclude 结束位置(不包含)

4

String s = StrUtil.hide(str1,startInclude,endExclude);//替换指定字符串的指定区间内字符为'*'

5

运行程序后查看被隐藏后为结果

注意事项
1

startInclude 开始位置(包含)

2

endExclude 结束位置(不包含)

推荐信息