Negating specific line end sequences in rlike regex

I want to match any line that does not end with 'CA' or 'CA[any number]'. How can I do that using rlike in MySQL? (Note it doesn't support ?! etc).

Here's the regex for a positive match, I just need a way to negate it: '^.*[C][A][0-9]?$'

(Due to an embarrassing architecture limitation, I don't want to use not rlike ...)


The trick is turning it into a description of what you do want to match. Something doesn't end in CA or CA(digit) when:

It ends with something other than A or digit, or

It ends with something other than A, then a digit, or

It ends with something other than C, then A, then a digit, or

It ends with something other than C, then A, or

It equals A followed by a digit, or

It equals A or a digit, or

It is empty.


rlike '[^A0-9]$|[^A][0-9]$|[^C]A[0-9]$|[^C]A$|^A[0-9]$|^[A0-9]$|^$'

Untested, un-"optimized", probably at least one error somewhere in the above.

Need Your Help

Best way to track initial mapping using KnockoutJs

javascript knockout.js knockout-mapping-plugin

I find that in my application I have the following pattern repeated a lot (see below code).

Instagram iphone hooks

javascript iphone ios instagram

Instagram has some cool hooks that can be used to open the app from a web url.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.