有没有办法通过编程替换这种情况?

大可山人
博客专家认证
2003-06-21 08:05:59
字串内容为:
“汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编”
我想将单数的“汇编”换为繁体“彙編”,如何实现?
...全文
47 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jeffrey_rui 2003-06-28
  • 打赏
  • 举报
回复
测试通过
int i=0;
string strold="汇编Asdafsa汇编Bsd汇编Csda汇编Dds汇编ds汇编ee汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编";
string strnew="";
string stroldpart="汇编";
string strnewpart="彙編";
while(strold.IndexOf(stroldpart)>=0)
{
if(i==0)
{
strnew+=strold.Substring(0,strold.IndexOf(stroldpart))+strnewpart;
strold=strold.Substring(strold.IndexOf(stroldpart)+stroldpart.Length);
i=1;
}
else
{
strnew+=strold.Substring(0,strold.IndexOf(stroldpart))+stroldpart;
strold=strold.Substring(strold.IndexOf(stroldpart)+stroldpart.Length);
i=0;
}
}
strnew+=strold;
大可山人 2003-06-28
  • 打赏
  • 举报
回复
我的意思是指定替换,比如:
“汇编Asdafsa汇编Bsd汇编Csda汇编Dds汇编ds汇编ee汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编”
可能在“汇编”两个字中间插入了许多其他的字符。
例如:<a href="/a.asp">这是第一个网页</a>
<a href="http://www.domain.com/news/a.asp">这是第二个网页</a>
<a href="../../a.asp">这是第三个网页</a>
<a href="../../a.asp">这是第四个网页</a>
我想将链接到第三个网页的"a.asp"替换成"b.asp"(即指定替换),但第四个链接又不要替换。
gxboy 2003-06-28
  • 打赏
  • 举报
回复
<%
Dim content As String = "汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编"
Dim contnum As Integer = Len(content)
Dim i As Byte

For i = 1 to contnum step 4
a = left(content,2) + Replace(mid(content,1,2),"汇编","彙編")
response.write(a)
Next
%>

这个可以达到你的实现。
大可山人 2003-06-28
  • 打赏
  • 举报
回复
字串内容为:
“汇编Asdafsa汇编Bsd汇编Csda汇编Dds汇编ds汇编ee汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编汇编”
我想将单数的“汇编”换为繁体“彙編”,如何实现?
大可山人 2003-06-21
  • 打赏
  • 举报
回复
急呀。。。。没有办法吗?

62,052

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧