从数据库中的搜索(NodeJS)返回正则表达式模式 [英] Return a Regex Pattern from a search in database (NodeJS)

查看:112
本文介绍了从数据库中的搜索(NodeJS)返回正则表达式模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Redis,但是任何数据库中的示例(对NodeJS都适用)将有助于我前进。

I'm currently using Redis, but examples in any database (that are good with NodeJS) would be good to get me going.

我正在寻找通过提供潜在的匹配项,从列表中找到正则表达式模式。

I'm looking to find Regex Patterns from a list, by providing potential matches.

我想查询模式数据库并询问它:哪些模式会匹配此字符串?

I want to query my database of patterns and ask it - "which patterns would match this string?"

示例

模式数据库:

(\/some\/)

(\/relative\/)

(\/other\/)

搜索: / some / relative / url /

Search: "/some/relative/url/"

返回:

(\/some\/)

(\/relative\/)

搜索: / some / other / url /

Search: "/some/other/url/"

返回:

(\/some\/)

(\/other\/)

所以我的问题是:这可能吗?如果可以,怎么办?

So my question is: is this possible? If so, how?

推荐答案

(据我所知)仅使用redis调用是不可能的。我建议从数据库中加载所有正则表达式,然后在javascript中运行它们以找出匹配的正则表达式。

This is not possible (to my knowledge) using only redis call. I suggest loading all the regular expressions from the database and running them in javascript to figure out which ones match.

这篇关于从数据库中的搜索(NodeJS)返回正则表达式模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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