Tip: mySQL has REGEX built in

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Tip: mySQL has REGEX built in

Post by Cruzado_Mainfrm »

examples of regex:

will show artist that start with a number

Code: Select all

SELECT artistname FROM artists WHERE artistname REGEXP "^ї0-9]"
will return 1(boolean):

Code: Select all

SELECT "myword" REGEX "^my.*rd$"
will return 1(boolean):

Code: Select all

SELECT "that was nice" REGEX "&#1111;&#1111;:<:]]was&#1111;&#1111;:>:]]"
the reference:
http://www.mysql.com/doc/en/Regexp.html
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Thanks Cruzado, this post will surely save me an hour or so of time in the future.
Post Reply