凤来仪

专业的计算机学习网站

首页 > ASP循环替换字符串

ASP循环替换字符串

点击:861 发布时间:

在ASP中,如果想将字符串aaaabbaaaaaa中所有的aa替换为a,用replace执行一次操作后,结果为aabbaaa,依然含有aa。那么怎样让程序再继续进行替换,直到结果中不再含有aa呢?其实我们只要用个简单的循环语句就可以了。代码如下:

theText="aaaabbaaaaaa"
x="a"
While instr(theText,x&x)<>0
  theText=replace(theText,x&x,x)
Wend
response.write theText '返回结果:abba