[英]simple c# regex example
I am searching through a database schema text file where all stored procedures, functions, triggers and views are delimited by ";;". 我正在搜索数据库模式文本文件,其中所有存储过程,函数,触发器和视图均以“ ;;”分隔。 I am splitting the contents on the ";;"
我在“ ;;”上拆分内容 delimiter and then for each piece, looking for "CREATE PROCEDURE", "CREATE FUNCTION", "CREATE TRIGGER" or "CREATE VIEW".
定界符,然后为每块查找“创建过程”,“创建功能”,“创建触发器”或“创建视图”。 However, this search criteria could not be as perfect as I just listed.
但是,此搜索条件不能像我刚才列出的那样完美。 For example, "CREATE PROCEDURE" could be: "create PROCEDURE", "create procedure", "CREATE PROCEDURE", etc.
例如,“ CREATE PROCEDURE”可以是:“ create PROCEDURE”,“ create procedure”,“ CREATE PROCEDURE”等。
This looks like a pretty simple regex pattern to check for but I am new to regex and struggling a bit. 这看起来像一个非常简单的正则表达式模式,但我对正则表达式并不陌生,并且有点挣扎。 Any help would be appreciated.
任何帮助,将不胜感激。
var regex = new Regex(@"\bcreate\s+(procedure|function|view|trigger)" +
@"\s+(?<ObjectName>[a-z_][a-z0-9_]+)\b",
RegexOptions.IgnoreCase);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.