Jump to content

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)'

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.