Page 1 of 1

using preg_match to allow users to search

Posted: Tue Aug 02, 2005 3:55 pm
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.

Posted: Tue Aug 02, 2005 4:55 pm
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.

Posted: Tue Aug 02, 2005 6:01 pm
by Chris Corbyn
Moved to regex