Jump to content

Search with PHP with extra functionalities


srujana

Recommended Posts

Hi,

 

I want to check whether few statements are present in the database or not. A regular where condition is sufficient for this.

 

But my concern is that, the user may enter sentences like SMS short codes like

'txt' for text,

'dnt' for dont etc.

 

is there any easy way with PHP or MySQL than manually checking with our common sense?

 

 

Regular Expressions is a uhm.. part of most every major main stream language, such as PHP, MySQL, JavaScript, ActionScript, its basically a package I suppose you can call it, whatever it may be called

 

RegEx was created to match common or 'regular' expressions, in the form of patterns.. example:

 

/^he(?:y|llo)$/i

 

to match

'hey'

or

'hello'

 

php's regular expression functions are preg_match and preg_match_all for global searches..

 

MySQL uses somewhat of a 'command' to tell mysql that it is expecting a regular expression

 

SELECT *

FROM `table`

WHERE `field` REGEXP 'he(?:y|llo)'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.