using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(CREATE TABLE[^;]*;)";
string input = @"DROP TABLE IF EXISTS `admin_analytics_usage_version_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `admin_analytics_usage_version_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
`last_viewed_in_version` varchar(50) NOT NULL COMMENT 'Viewer last viewed on product version',
PRIMARY KEY (`id`),
UNIQUE KEY `ADMIN_ANALYTICS_USAGE_VERSION_LOG_LAST_VIEWED_IN_VERSION` (`last_viewed_in_version`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='Admin Notification Viewer Log Table';
but not CREATE TABLE `admin_analytics_usage_version_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
`last_viewed_in_version` varchar(50) NOT NULL COMMENT 'Viewer last viewed on product version',
PRIMARY KEY (`id`),
UNIQUE KEY `ADMIN_ANALYTICS_USAGE_VERSION_LOG_LAST_VIEWED_IN_VERSION` (`last_viewed_in_version`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='Admin Notification Viewer Log Table';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `admin_analytics_usage_version_log`
--
LOCK TABLES `admin_analytics_usage_version_log` WRITE;
/*!40000 ALTER TABLE `admin_analytics_usage_version_log` DISABLE KEYS */;
INSERT INTO `admin_analytics_usage_version_log` VALUES (5,'2.3.4-p2');
/*!40000 ALTER TABLE `admin_analytics_usage_version_log` ENABLE KEYS */;
UNLOCK TABLES;
CREATE TABLE `admin_analytics_usage_version_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
`last_viewed_in_version` varchar(50) NOT NULL COMMENT 'Viewer last viewed on product version',
PRIMARY KEY (`id`),
UNIQUE KEY `ADMIN_ANALYTICS_USAGE_VERSION_LOG_LAST_VIEWED_IN_VERSION` (`last_viewed_in_version`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='Admin Notification Viewer Log Table';
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx