0

我想根据字符串中是否包含某些单词、字符串中是否不存在或某种组合来过滤字符串列表。我希望输入简单明了,例如:

input: "foo AND bar"
output: All strings containing 'foo' and 'bar'

input: "foo OR bar"
output: All strings containing 'foo' or 'bar'

input: "foo AND NOT bar"
output: All strings containing 'foo' but not 'bar'

这写起来相当简单,但是有没有人已经这样做了,所以我不必以不太理想的方式重新发明轮子?这将是面向用户的,我不希望用户必须学习如何使用正则表达式。

4

1 回答 1

0

我不知道任何库,但您可以使用 jQuery 的 :contains 选择器轻松编写类似的内容。

http://api.jquery.com/contains-selector/

于 2012-09-04T19:54:35.677 回答