DevNewz News Archives About Us Feedback

Recent Articles

Use an HttpModule to Spam-proof Your Website
Every time an email address is written on a website, it allows spam robots to collect it and abuse it. If you have a website (e.g. blog or forum) that displays the users e-mail address it would be a nice service to mask it for...

Web Developers Vs. Traditional Developers on CSS
In the year of 2006 it can be hard to avoid doing web development to some extent no matter what kind of developer you are.

Top AIM Developer Now With Google
Justin Uberti announced Saturday that he has left AOL after nearly 10 years as a lead developer for the company's widely utilized AOL Instant Messenger software.

Countdown To Oracle Open World: OAUG SIG's
If you are heading out to San Francisco for Oracle Open World a bit early and have some free time on Sunday the 22nd, you will want to take advantage of the 5th Annual OAUG Oracle Users Forum being held at the...

Grokking The Source
Jeff Atwood has an interesting observation at http://www.codinghorror.com/blog/archives/000684.html: if you actually observe what software developers spend their time doing, you'll find that they spend most of...

11.09.06


MySQL's Regular Expression Support

By Raymond Camden

Many months ago I reviewed Ben's MySQL Crash Course, an excellent book that discusses MySQL at a very high, quick to read level.

One of the cool things I discovered was that MySQL supports regex in SQL queries. How about some examples....

Consider a typical OR style search like the query below:

select id
from products
where name like '%alpha%'
or name like '%beta%'


By using the regex support in MySQL, you can rewrite it as:

select id
from products
where name regexp '(alpha|beta)'


MySQL doesn't support the full set of regular expressions you use in ColdFusion or Perl, but it does support most of what you would use normally.

Low Rate eCommerce & Retail Plans

That includes beginning and end of line matches, character classes, ranges, and matching certain numbers of items.

A few more quick notes: The MySQL Regex escape character is two back slashes.

So for example, \\. will escape the . character.

Secondly - to do case sensitive regular expressions, you use the binary keyword:

select id
from products
where name regexp binary 'Camden'


Lastly - do know that when you use regex in MySQL, the engine has to check each and every line to see if your regex matches.

This may lead to slower performance.


About the Author:
Raymond Camden is Vice President of Technology for roundpeg, Inc. A long time ColdFusion user, Raymond has worked on numerous ColdFusion books and is the creator of many of the most popular ColdFusion community web sites. He is an Adobe Community Expert, user group manager, and the proud father of three little bundles of joy.

About DevNewz
DevNewz has assembled experts around the world to deliver helpful advice to application developers. Our in-house news staff focuses on keeping you updated with the latest new software and trends in application development. DevNewz provides Knowlege For Application Developers.

DevNewz is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagementNews.com


-- DevNewz is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2006 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


Knowlege For Application Developers DevNewz Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact