asp字符转换问题

来源:百度知道 编辑:UC知道 时间:2024/06/21 09:07:02
从数据库里读出x=1 2 3 4 5
怎么样让它输入为a1b1c a2b2c a3b3c a4b4c a5b5c
3 4 5 这里是多外空格,1 2 3这中间是一个空格

dim xx()
dim n
xx=split(x," ")
n=ubound(xx)
for i=0 to n-1
xx(i)="a"+xx(i)+"b"+xx(i)+"c"
next i
for i=0 to n-1
x=x+" "+xx(i)
next i
x=trim(x)

咱们来一个用正则表达式替换的:^_^
x="1 2 3 4 5"
set xx=new regexp
xx.pattern="(\d+)"
xx.global=true
x=xx.replace(x,"a$1b$1c")
response.Write(x)