Solved

negated character class in mysql regexp

Posted on 2010-11-24
8
336 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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 500 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now