Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-25-2021, 10:48 PM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,128
REGEXP not working right?

This is what I am using:

Quote:
SELECT * FROM Recipe WHERE Category REGEXP '/(?=.*?(seafood))(?=.*?(lunch))/is' ORDER BY RAND() LIMIT 5;");
I want it to display the results for rows that contain both the words (any cAsE) 'seafood' AND 'lunch' in the Category column, it doesnt like my expression though for some reason, any pointers please?

I was under the impression i could use the following to do what I wanted:

Quote:
SELECT * FROM Recipe WHERE Category REGEXP '(?=.*seafood)(?=.*lunch)' ORDER BY RAND() LIMIT 5;");
But it doesnt seem to like that either
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-26-2021, 03:24 AM   #2
faperoni
Confirmed User
 
faperoni's Avatar
 
Industry Role:
Join Date: Feb 2015
Location: Amsterdam
Posts: 210
Maybe LIKE works better for you

Code:
SELECT * FROM Recipe WHERE Category LIKE '%seafood%' OR Category LIKE '%lunch%' ORDER BY RAND() LIMIT 5;");
if the keyword is always at the end of the string you can also use

Code:
SELECT * FROM Recipe WHERE Category LIKE '%seafood' OR Category LIKE '%lunch' ORDER BY RAND() LIMIT 5;");
Maybe its better to extract these keywords and put them in a separate table? LIKE (or REGEXP) are "slow".

More pattern matching examples and options:
https://dev.mysql.com/doc/refman/8.0...-matching.html
__________________
Faperoni.com Fucker.com
faperoni is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-26-2021, 07:11 AM   #3
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
Faperoni is right, you should consider just using like. REGEXP is hard as fuck and if you are a beginner you simply aren't going to be able to grasp it just yet because people who have been coding for 20 years have issues with it.
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2021, 05:26 PM   #4
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,075
Quote:
Originally Posted by k0nr4d View Post
Faperoni is right, you should consider just using like. REGEXP is hard as fuck and if you are a beginner you simply aren't going to be able to grasp it just yet because people who have been coding for 20 years have issues with it.
This ^^^^^

I've been slamming code for a hell of a long time and hate the fuck out of reguar expressions.

Like will do it for you most of the time.

.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
regexp, category, rand, limit, 5;;, recipe, select, impression, pointers, reason, crap, ?=.?=., apparently, expression, /?=.?seafood?=.?lunch/is, display, results, rows, lunch, column, seafood, words



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.