I have a very interesting task, which I do not know how to implement.
I need to save a lot of regular expressions in a database table and need to find which one matches this row.
For instance:
id | regexp
---|-------------
1 | ^hello world$
2 | ^I have [0-9] flowers&
3 | ^some other regexp$
4 | ^and another (one|regexp)$
And I need to find which of these expressions matches the line "I have 5 colors." Of course, I can SELECT * FROM table and quote the expressions corresponding to them one by one in PHP, but that would be terrible for the server processing.
Is there any way to index this table or use a special SQL query to handle this task?
I would appreciate any response. Thank.