0

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?"

Example

Pattern Database:

(\/some\/)

(\/relative\/)

(\/other\/)

Search: "/some/relative/url/"

Return:

(\/some\/)

(\/relative\/)

Search: "/some/other/url/"

Return:

(\/some\/)

(\/other\/)

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

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I thought that myself, but I thought I'd ask to see if anyone can come up with something.
Excuse the original answer mentioning SQL. I knew you were talking about redis, which is why I answered as I did. There are ways to do this in SQL, but I guess thats not your question.
0

I think there is a way to that. You need to treat the pattern to be stored as a string, then retrieve them as you retrieve any other string from the redis datastore. Just for your reference I am giving a link to redis-nodejs tutorial I found - Using Redis With Nodejs.

1 Comment

Further you can also read the following question stackoverflow.com/questions/30837762/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.