By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,679 Members | 1,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,679 IT Pros & Developers. It's quick & easy.

MySql REGEXP Problem

P: 44
I've been using regular expressions for a few months, but I've hit a problem I can't figure out. I need a MySQL regexp to match a string made up of a sequence of characters occurring only 0 or 1 times. For example, for characters 'a', 'b', and 'c', I want to match to 'a', 'b', 'c', 'ab', 'ac', 'ba', 'bc', 'ca', 'cb', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', and nothing else.

My problem is that I'm getting things like 'abcd' showing up because the 'abc' pattern is in there, but I want to match to an exact string, not a pattern existing somewhere in the string. I've gone thought dozens of different regular expressions and I can't get what I'm looking for. Any suggestions?
Sep 22 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 310
\b is a whole word break inidicater, meaning that

Expand|Select|Wrap|Line Numbers
  1. \babc\b
  2.  
should match abc which is not part of any string. You could maybe wrap the rest of your regexp expression in the \b tags.
Sep 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.