【发布时间】:2012-08-29 12:13:17
【问题描述】:
我想根据字符串中是否包含某些单词、字符串中是否不存在或某种组合来过滤字符串列表。我希望输入简单明了,例如:
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'
这写起来相当简单,但有没有人已经这样做了,所以我不必以不太理想的方式重新发明轮子?这将面向用户,我不希望用户必须学习如何使用正则表达式。
【问题讨论】:
-
这些语句要“编译”成正则表达式?数据库查询?你的最终目标是什么?
-
哦,我以为很清楚;让我更新我的问题
-
我怀疑 Javascript 中是否存在类似的东西
-
@SimpleCoder:同样,我想我还是会问
标签: javascript user-interface pattern-matching string-matching