使用ASP进行关键字解析 [英] Keyword Parsing with ASP

查看:75
本文介绍了使用ASP进行关键字解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在ASP(VBScript)中编写一个搜索程序。用户可以输入关键字

并按提交。

用户可以用空格和/或逗号分隔关键字,关键词可以

包含简单的单词,单引号的字符串(短语),双引号的字符串

(短语)。

例如:


关键词:


Jack,Jill,Jim,Timothy Brown,Mary或

Jack Jill Jim''Timothy Brown''Mary OR

Jack,Jill Jim,''Timothy Brown''" Mary"


当我解析它时,我将关键字存储在一个数组中。结果必须是:


Jack

Jill

Jim

Timothy Brown

Mary


我尝试过使用Split这样做,但我无法获得短语。一些

建议,代码示例或链接会有所帮助。


提前致谢


ARK。

I am writing a search program in ASP(VBScript). The user can enter keywords
and press submit.
The user can separate the keywords by spaces and/or commas and key words may
contain plain words, single quoted strings (phrases), double quoted strings
(phrases).
For example:

Keywords:

Jack, Jill, Jim, "Timothy Brown", Mary OR
Jack Jill Jim ''Timothy Brown'' Mary OR
Jack, Jill Jim, ''Timothy Brown'' "Mary"

When I parse it i store the keywords in an array. The results must be:

Jack
Jill
Jim
Timothy Brown
Mary

I have tried doing this using Split but am unable to get the Phrases. Some
suggestions, code examples or links would help.

Thanks in advance

ARK.

推荐答案

您可能希望用逗号替换用户输入的空格,然后使用split命令替换



strVariable =替换(strVariable,",",")

拆分(strVariable,",")

>
然后你应该有你的一系列物品。


hth,

Andrew


* * *通过DevBuilder发送 http://www.devbuilder.org * * *

高端开发人员的开发人员资源。
You might want to replace the spaces the user puts in with commas and
then use the split command.

strVariable = Replace(strVariable," ",",")
Split(strVariable,",")

Then you should have your array of items.

hth,
Andrew

* * * Sent via DevBuilder http://www.devbuilder.org * * *
Developer Resources for High End Developers.


不幸的是,这会在Timothy Brown中添加一个逗号。还有。


我的建议是在

时间通过字符串一个字符。如果字符是空格,而不是引号(或),则添加

a逗号,否则移动



" ; Andrew J Durstewitz <广告****** @ devbuilder.org>在消息中写道

新闻:3f *********************** @ news.frii.net ...
Unfortunately, that would put a comma in "Timothy Brown" as well.

My suggestion would be to work your way through the string a character at a
time. If the character is a space, and not within quotes (" or '') then add
a comma, otherwise move along


"Andrew J Durstewitz" <ad******@devbuilder.org> wrote in message
news:3f***********************@news.frii.net...
您可能希望用逗号替换用户输入的空格,然后使用split命令。

strVariable = Replace(strVariable,"",", ")
分裂(strVariable,,)
然后你应该有你的项目数组。

hth,
Andrew

* * *通过DevBuilder发送 http://www.devbuilder.org * * *
高端开发人员的开发人员资源。
You might want to replace the spaces the user puts in with commas and
then use the split command.

strVariable = Replace(strVariable," ",",")
Split(strVariable,",")

Then you should have your array of items.

hth,
Andrew

* * * Sent via DevBuilder http://www.devbuilder.org * * *
Developer Resources for High End Developers.



>我的建议是通过字符串在
a
> My suggestion would be to work your way through the string a character at
a
时间通过字符串。如果字符是空格,而不是引号(或),则
添加逗号,否则沿着移动
time. If the character is a space, and not within quotes (" or '') then add a comma, otherwise move along




这可以无限制地获得复杂,例如,b $ b鲍勃,玛丽,蒂莫西,布朗 ''franke,'tom,hula hoop" mea,culpa"


你永远不知道用户将要输入什么,并且编写代码很难

完全理解他们的意思。


我真的很想知道Google的解析算法是如何工作的。我没有勇气做到这一点: www.aspfaq.com 支持所有单词,任何

单词或精确短语......但不包含三者的组合。



This can get infinitely complex, e.g.

Bob, Mary, "Timothy, Brown" ''franke, "tom, hula hoop" mea, culpa"

You never know what a user is going to enter, and it''s hard to write code to
understand exactly what they mean.

I''d be really interested to see how Google''s parsing algorithm works. I
wasn''t brave enough to do that: www.aspfaq.com supports all words, any
words, or exact phrase... but no combination of the three.


这篇关于使用ASP进行关键字解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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