using preg_match to allow users to search

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
BHarris
Forum Newbie
Posts: 7
Joined: Thu Jun 09, 2005 3:46 pm
Location: West Virginia
Contact:

using preg_match to allow users to search

Post by BHarris »

I want to allow users to include a wildcard character in a search for a value which may follow any one of the following formats: "%4%" or "23%", however, this should not allow the user to input an single quote. Basically, I am searching for a room number but since the room number can range from something such as G35,12LG, or 135C, 135D, I need to know exactly how I can go about doing this. I really have no code per se, so if anyone has any suggestions, I would be grateful.

Thanks.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

If you have the rooms stored in an SQL server, you can probably use the keyword LIKE to do something somewhat like that. It's generally, however, not a good idea to let users directly pass regexps to the script.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Moved to regex
Post Reply