Welcome to WebmasterWorld Guest from 50.17.114.227

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)

New User

10+ Year Member

joined:June 24, 2005
posts:21
votes: 0


Hi,
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 Sept 21, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 7, 2004
posts:929
votes: 0


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 Sept 21, 2005 (gmt 0)

New User

10+ Year Member

joined:June 24, 2005
posts:21
votes: 0


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