正则表达式提取string 中的表名

简单版本:

Regex reg = new Regex(@"(?i)\bfrom\b(?![^\[\]]*\])\s+(\[[^\[\]]+\]|\S+)");
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
    richTextBox2.Text += m.Groups[1].Value + "\n";
}

支持过滤join,left join等复杂联表过滤表名

Regex reg = new Regex(@"(?in)\b(from|(left|right|INNER)\s+join)\b(?![^\[\]]*\])\s+(?<table>\[[^\[\]]+\]|\S+)");
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
    richTextBox2.Text += m.Groups["table"].Value + "\n";
}

原帖: http://bbs.csdn.net/topics/330116986

时间: 2024-08-30 02:50:03

正则表达式提取string 中的表名的相关文章

MySql 查询数据库中所有表名

查询数据库中所有表名select table_name from information_schema.tables where table_schema='csdb' and table_type='base table'; 查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='csdb' and table_name='users'

django中自定义表名及字段名称

在meta 类中指定表名,在字段中通过db_column指定列名如下所示 class Record(models.Model): content=models.CharField(max_length=32,db_column='record_content') class Meta: db_table="Record"

C#正则表达式提取文本中以逗号间隔的数据

使用正则表达式提取文本数据到内存是很方便的技术,下面通过一个例子介绍一下如何使用正则表达式提取文本 文本中内容格式 1,2,3,4,5 2,2,2,2,2 3,3,3,3,3 C#代码如下 public List<List<string>> GetDataCSV(string path) {         string pattern = @"\d+"; List<List<string>> data = new List<Lis

爬虫(四):正则表达式(提取str中网址)

3.采用beatifulsoup与re正则表达式一起使,提取html中的一些href的链接 http://cuiqingcai.com/1319.html 4.如何利用正则表达式边界匹配

解析sql中的表名

最近的项目需求中需要解析sql得表名,由于只需要表名我觉得应该用相对粗暴一点的方式来解析 初步思路: 1.转义字符:去除两个引号连在一起的 2.字符串: 去除所有被引号包裹的 3.括号:识别括号处理 4.关键字: 用关键字切割语句,去除与表名 无关的 5.解析与表名有关的切割分段得表名 先是粗暴的括号处理 def get_str(s): you = 0 st = [] re = '' max_you = 0 for ii in s: st.append(ii) while st: tmp = s

在mysql中修改表名的sql语句

在使用mysql时,经常遇到表名不符合规范或标准,但是表里已经有大量的数据了,如何保留数据,只更改表名呢?可以通过建一个相同的表结构的表,把原来的数据导入到新表中,但是这样视乎很麻烦.能否简单使用一个SQL语句就搞定呢?当然可以,mysql5.0下我们使用这样的SQL语句就可以了.ALTER TABLE table_name RENAME TO new_table_name例如 ALTER TABLE admin_user RENAME TO a_us

获取dbf中的表名

因为特殊需要,需要获取dbf数据库中的表的名称.现有 如下解决办法 1 public List<string> GetTableFields(string path) 2 { 3 List<string> tables = new List<string>(); 4 var dt = GetSchemaTable(ConnectionString); 5 foreach (DataRow dr in dt.Rows) 6 { 7 tables.Add(dr["

Oracle中修改表名遇到“ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效”

Oracle中想修改表名: rename ASSETPORJECT to ASSETPROJECT; --结果提示:ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效. 看来有锁定该表的会话,于是,执行如下查询: SELECT sid, serial#, username, osuser FROM v$session where sid in(select session_id from v$locked_object); --kill掉相关的会话 ALTER

Oracle 查询库中所有表名、字段名、表名说明、字段名说明(原创)

查询所有表名:select t.table_name from user_tables t;查询所有字段名:select t.column_name from user_col_comments t;查询指定表的所有字段名:select t.column_name from user_col_comments t where t.table_name = 'BIZ_DICT_XB';查询指定表的所有字段名和字段说明:select t.column_name, t.column_name from