Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

negated character class in mysql regexp

Posted on 2010-11-24
8
Medium Priority
?
353 Views
Last Modified: 2012-06-27
Hi

In mysql regexp how do you specify a negated character class? By this i mean something like

not [atcg]

i.e. anything other than those 4 letters

thanks
0
Comment
Question by:andieje
  • 5
  • 3
8 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 34210270
regexp '[^(a|t|c|g)]'

... or

not regexp '(a|t|c|g)'
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34210308
ignoring case:

regexp '[^(aA|tT|cC|gG)]'

.. or

NOT regexp '(aA|tT|cC|gG)'
0
 

Author Comment

by:andieje
ID: 34227301
hi that's not what i meant. I wanted to use the negated character class as part of a larger regular expression please.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 52

Expert Comment

by:_agx_
ID: 34235675
Depends on the existing expression.  Can you post it and describe what you're trying to add to that expression?
0
 

Author Comment

by:andieje
ID: 34248772
where column REGEXP '^[ATCG]/<negated character class goes here>'

so i want to match and a,t,c or g at the start followed by a slash followed by a character that is NOT atcg
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 34253625
WHERE column REGEXP '^[ATCG]/[^ATCG]'

0
 

Author Closing Comment

by:andieje
ID: 34262443
simple enough :)
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34264007
... and almost symmetrical too :)
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question