从查询字符串中删除单词 [英] stripping words from querystring

查看:97
本文介绍了从查询字符串中删除单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试传递查询字符串,其中删除了某些常用词(并且,

,if,of etc.)。以下代码将关键字替换为"或者我选择的其他任何东西,但我想要做的是从

查询字符串中完全删除这些单词。如何删除而不是替换?


谢谢


*********

tempstr = searchstring


removewords = array("",""," if"," of"," a")

temp = trim(tempstr)


for x = 0 to ubound(removewords)

temp = replace(temp,removewords(x)," ")

next


newstring =修剪(临时)

解决方案

David写道:



我正在尝试传递一个查询字符串,其中删除了某些常用字词
(以及,等等) 。下面的代码将关键字替换为"
或我选择的任何内容,但我想要做的是从查询字符串中完全删除单词
。我该如何删除而不是替换?

谢谢

tempstr = searchstring

删除词= array("",""," if"," of of,a")
temp = trim(tempstr)

for x = 0 ubound(删除词)
temp = replace(temp,removewords(x),"")
下一页

newstring = Trim(temp)




我不明白。用空字符串替换字符就像删除它们一样。

。你可以重新提一下你的问题吗?

鲍勃巴罗斯


-

微软MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

NO SPAM


Bob Barrows于2004年2月15日在

microsoft.public.inetserver.asp.general:

我不明白。用空字符串替换字符与删除字符完全相同。你可以重新写一下你的问题吗?


鲍勃,当删除单词时会留下双倍空格。


另外一个问题:

removewords = array("",""," if"," of,a")
temp = trim(tempstr)

for x = 0 to ubound(removewords)
temp = replace(temp,removewords(x),"")
next




猫已经冒犯了他们的妻子


将改为


" ct hs fended ir we


我建议这样:


=============== ===========


removewords = array("",""," if"," of"," a" ;)

temp =" " &安培; trim(tempstr)& "


for x = 0 to ubound(removewords)-1

temp = replace(temp,""& removewords(x)& ;"","")

next


result = trim(temp)

==== ======================

-

Evertjan。

荷兰。

(请在我的电子邮件地址中将x'变为点数)


>我建议这样:

< snip>


谢谢 - 工作待遇!


David

Hi,

I''m trying to pass a querystring with certain common words removed (and,
the, if, of etc). The code below replaces the keywords with "" or whatever I
choose, but what I''d like to do is remove the words completely from the
querystring. How do I remove rather than replace?

Thanks

*********
tempstr=searchstring

removewords = array ("and","the","if","of","a")
temp=trim(tempstr)

for x=0 to ubound(removewords)
temp=replace(temp,removewords(x),"")
next

newstring=Trim(temp)

解决方案

David wrote:

Hi,

I''m trying to pass a querystring with certain common words removed
(and, the, if, of etc). The code below replaces the keywords with ""
or whatever I choose, but what I''d like to do is remove the words
completely from the querystring. How do I remove rather than replace?

Thanks

*********
tempstr=searchstring

removewords = array ("and","the","if","of","a")
temp=trim(tempstr)

for x=0 to ubound(removewords)
temp=replace(temp,removewords(x),"")
next

newstring=Trim(temp)



I don''t understand. Replacing characters with an empty string is exactly the
same thing as removing them. Could you reprase your question?
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


Bob Barrows wrote on 15 feb 2004 in
microsoft.public.inetserver.asp.general:

I don''t understand. Replacing characters with an empty string is
exactly the same thing as removing them. Could you reprase your
question?

Bob, when removing words double spaces are left.

Also another problem:
removewords = array ("and","the","if","of","a")
temp=trim(tempstr)

for x=0 to ubound(removewords)
temp=replace(temp,removewords(x),"")
next



"the cat has offended their wife"

will be changed to

" ct hs fended ir we"

I would suggest this:

==========================

removewords = array ("and","the","if","of","a")
temp= " " & trim(tempstr) & " "

for x=0 to ubound(removewords)-1
temp=replace(temp, " " & removewords(x) & " "," ")
next

result = trim(temp)
==========================

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


> I would suggest this:
<snip>

Thanks - works a treat!

David


这篇关于从查询字符串中删除单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆