Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

How To Match A Regular Expression With Another Regular Expression?

Mysql. Tricky Stuff.



6:36 am on Sep 21, 2005 (gmt 0)

10+ Year Member

I am trying to match a regular expression with another regular expression that is stored inside a row in a table in mysql.

a. good +morning girl -afternoon
b. good +morning -girl <-- this stores inside the DB.

Don't need to say, they won't match because of word "girl". This is exactly what I want.

How do I write a query this do this? I was think of usine REGEXP, but it's hard still because I am matching a target which is a regular expression not a string. Things can get much more complicate when I combine a bunch of "and" and "or" and "not" statements.

Many thanks.


7:00 am on Sep 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Not sure I can help coz it is tricky stuff as you say and I may got it wrong.

Let me just suggest that I would explode() your regular expression, separators being your "and", "or", etc. and other popular statements you may use.

Then, compare each element of your regular with each element of your "master" regular expression by using the similar_text() function.

Am I right? It is just a guess!


4:22 pm on Sep 21, 2005 (gmt 0)

10+ Year Member

Convert to "and", "or", "not" statements is easy, but match both is not. similar_text() won't help.

For examples:

a. good AND morning NOT afternoon
b. good OR morning

They don't match because b can be just "good" and a can be "good morning".


Featured Threads

Hot Threads This Week

Hot Threads This Month