社区
Java SE
帖子详情
还是replaceAll的问题
ppxstar
2002-11-18 06:02:24
replaceAll,是不是不能替用substring取出来的字符串呀??
...全文
24
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
JS中实现
replaceAll
的方法(实例代码)
本文是对JS中实现
replaceAll
的方法进行了详细的总结介绍,需要的朋友可以过来参考下,希望对大家有所帮助
JavaScript中使用replace结合正则实现
replaceAll
的效果
JavaScript 中使用 replace 达到
replaceAll
的效果,其实就用利用的正则的全局替换。
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" ; ...
Java SE
62,616
社区成员
307,307
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章