NYCPHP Meetup

NYPHP.org

[nycphp-talk] Regular Expression Assistance in MySQL

Peter Sawczynec ps at pswebcode.com
Tue Jul 19 07:10:59 EDT 2005


"West ", but that won't match "West." or "West," or similar matches. You
need to really think about what you're trying to hit.

-adam

Using the additional above input from Adam, here is more refinements to the
criteria.

[ Cannot be any alphanum character. Could be no space. Could be a space.
Could be any punctuation, except not a dash (-). ]
SEARCH TERM 
[Cannot be any alphanum character. Could be no space. Could be a space.
Could be any punctuation, except not a dash (-). ]

I believe this is the criteria the reg exp needs to meet.

Peter


-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of David Mintz
Sent: Monday, July 18, 2005 10:34 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Regular Expression Assistance in MySQL


On Mon, 18 Jul 2005, Peter Sawczynec wrote:

> The West and a Western South-westerly Revolt
>
> What is the reg exp that would match only the freestanding West and 
> not match the West in Western or South-westerly.

This seems to work:

mysql> SELECT 'The West and a Western South-westerly Revolt' REGEXP 
mysql> BINARY
'[[:<:]]West[[:>:]]' as matches;

+---------+
| matches |
+---------+
|       1 |
+---------+
1 row in set (0.01 sec)

(http://dev.mysql.com/doc/mysql/en/regexp.html)

---
David Mintz
http://davidmintz.org/ _______________________________________________
New York PHP Talk Mailing List
AMP Technology
Supporting Apache, MySQL and PHP
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org





More information about the talk mailing list