社区
Java SE
帖子详情
还是replaceAll的问题
ppxstar
2002-11-18 06:02:24
replaceAll,是不是不能替用substring取出来的字符串呀??
...全文
40
9
打赏
收藏
还是replaceAll的问题
replaceAll,是不是不能替用substring取出来的字符串呀??
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
9 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
abcdhy
2002-11-19
打赏
举报
回复
replaceAll
就是使用一个字符串替换另一个字符串啊
只要你原来是一个字符串就可以用的
public String replaceAll(String regex,String replacement)
函数的返回值就是你要的字符串
signboy
2002-11-19
打赏
举报
回复
嗬嗬,解决问题为首要
ppxstar
2002-11-19
打赏
举报
回复
但是我试着替换的时候根本不能成功
程序没有出问题,编释也成功
但就好象是替换语句没执行一样
我也不想用自己写的replaceAll,因为会增加程序的复杂性
wes109
2002-11-18
打赏
举报
回复
是不是不能替用substring取出来的字符串呀??
取出来的还是不是String??
是!!
So 可以!!!
signboy
2002-11-18
打赏
举报
回复
public static String replaceAll(String str, String old, String news)
{
if(str == null)
return str;
int begin = 0;
int idx = 0;
int len = old.length();
StringBuffer buf = new StringBuffer();
while((idx = str.indexOf(old, begin)) >= 0)
{
buf.append(str.substring(begin, idx));
buf.append(news);
begin = idx + len;
}
return new String(buf.append(str.substring(begin)));
}
javawolf
2002-11-18
打赏
举报
回复
* Replaces each substring of this string that matches the given <a
* href="../util/regex/Pattern.html#sum">regular expression</a> with the
* given replacement.
看样子应该可以适用于所有String,substring也是String啊
ppxstar
2002-11-18
打赏
举报
回复
救命呀!!
ppxstar
2002-11-18
打赏
举报
回复
嗳,人家说java之中无高手,原来是真的
ppxstar
2002-11-18
打赏
举报
回复
有急用,请大伙多帮忙!!
ReplaceAll
ReplaceAll
多文件文本批量替换工具 依赖.net framework2.0
String.prototype.
replaceAll
:适用于String.prototype.
replaceAll
ESnext提案的符合规范的polyfill
string.prototype.
replaceall
用于String.prototype.
replaceAll
的ES Proposal规范填充程序。 如果不可用或不String.prototype.
replaceAll
调用其“ shim”方法对String.prototype.
replaceAll
进行填充。 该软件包...
replaceall
:替换 JavaScript 字符串中的所有实例
var
replaceall
= require("
replaceall
"); 使用替换 var result =
replaceall
( "instances of this" , "with this string" , "in this string" ) ; 例子 var original = "hello world goodbye world" ; ...
Chrome浏览器
replaceAll
报错
问题
Chrome浏览器
replaceAll
报错
问题
JavaScript中实现
replaceAll
方法
我们在Java中可以使用
replaceAll
()方法对字符串进行批量替换,但在JS中
replaceAll
()方法是undefined,JS中只存在replace()方法,因此我们可以自己封装JS中
replaceAll
()方法供我们便捷使用。 一、使用replace()方法...
Java SE
62,629
社区成员
307,262
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章