First of all, this does not work for my question. EDIT: I use Golang, whose regex support is documented here.
I am writing a schema management tool for mysql, which I need to do a replace from:
CREATE TABLE `sometable`
to
CREATE TABLE IF NOT EXISTS `sometable`
Originally, I just use CREATE TABLE\s+
to do the match, but in some case it will generate result like:
CREATE TABLE IF NOT EXISTS IF NOT EXISTS `sometable`
So I consider to write an regular expression to match CREATE TABLE when and only when it is not followed by IF NOT EXISTS. More precisely, if the string is CREATE TABLE IF NOT EXISTS
, I want the regex to NOT match it at all, rather than match the CREATE TABLE in it.