ASP查询替换问题,请大家帮帮我,分不够再加!

myfc 2003-11-30 11:06:24
我想在一段数据中用类似于通配符的形式查找东西,如:

content = "12345 143275 1342765 123467 2345" '这个content变量是不定的

我想在content中查找类似于1*5,然后替换他们,如替换为6*9
则content = "62349 643279 6342769 123467 2345"
注意,如果在一定范围内1和5没有成对出现则不被替换,如content中1和5成对出现最大范围为7位,而后面的1和5则相隔11位就没有被替换。

不知哪位高人可以解决此问题,请帮帮我啊!急用,分数如果不够我再加。
...全文
55 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
ghlfllz 2003-11-30
  • 打赏
  • 举报
回复
呵alexzhang00(三角猫(sjcatsoft)) 已经先我发了
ghlfllz 2003-11-30
  • 打赏
  • 举报
回复
我来替你写一个
dim endvalue
endvalue=""
content="12345 143275 1342765 123467 2345"
tmparray=split(content," ")
for i=0 to ubound(tmparray)
if left(tmparray(i),1)="1" and right(tmparray(i),1)="5" then
endvalue=endvalue&"6"&mid(tmparray(i),2,len(tmparray(i))-2)&"9"&" "
else
endvalue=endvalue&tmparray(i)&" "
end if
next
endvalue=left(endvalue,len(endvalue)-1)
content=endvalue
DeltaCat 2003-11-30
  • 打赏
  • 举报
回复
<%
content = "12345 143275 1342765 123467 2345"
arr = split(content," ")
for i=lbound(arr) to ubound(arr)
if left(arr(i),1)= "1" and right(arr(i),1)="5" and len(arr(i)) = 7 then
arr(i) = "6" & left(arr(i),len(arr(i))-2) & "9"
end if
next
content = join(arr," ")

response.write content
%>
myfc 2003-11-30
  • 打赏
  • 举报
回复
猫兄,我说的是在asp中,不是在sql中,有办法么?
myfc 2003-11-30
  • 打赏
  • 举报
回复
执子之手能不能说的再清楚一些呢??
myfc 2003-11-30
  • 打赏
  • 举报
回复
哦!对了!^_^!谢谢猫兄,也谢谢浪子!部门一人20,没问题吧!
DeltaCat 2003-11-30
  • 打赏
  • 举报
回复
每个_表示一位
DeltaCat 2003-11-30
  • 打赏
  • 举报
回复
select content from table where content like '1_____5'
aspczlover 2003-11-30
  • 打赏
  • 举报
回复
用instr()+split()+replace()
woodwolf 2003-11-30
  • 打赏
  • 举报
回复
学习
myfc 2003-11-30
  • 打赏
  • 举报
回复
哦??我再试试!不能冤枉了猫兄啊!^o^
DeltaCat 2003-11-30
  • 打赏
  • 举报
回复
其中7,是你要限制的长度啊,你自己设定啊
DeltaCat 2003-11-30
  • 打赏
  • 举报
回复
我的方法只替换了一个?
不可能啊
<%
content = "12345 143275 1342765 123467 2345"
arr = split(content," ")
for i=lbound(arr) to ubound(arr)
if left(arr(i),1)= "1" and right(arr(i),1)="5" and len(arr(i)) <= 7 then
arr(i) = "6" & left(arr(i),len(arr(i))-2) & "9"
end if
next
content = join(arr," ")

response.write content
%>

我的方法,你要自己领会啊,我的 len(arr(i)) <= 7 只是个例子,你自己根据你的意思改就可以了啊
myfc 2003-11-30
  • 打赏
  • 举报
回复
我刚刚试过,猫兄的代码只替换了最后一个,浪子的代码是全部替换的,不过我把content中"123467 2345"的空格去掉后即"1234672345",它们的距离大于7位了,还是被替换了
……………………
兄弟们有办法么??(有点儿太贪了,不过真的是急用的,谢谢各位了)

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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