notepad++使用正则表达式来搜索超过30个字符的字符串,忽略时间 - Notepad++ use regex to search strings longer than 30 characters and ignore periods if any

- 此内容更新于:2015-12-20
主题:

我是一个OracleDBA使用记事本++和需要帮助搜索。这是要求。我有一个巨大的DDL脚本生成的欧文。我想知道如果任何约束的名字是超过30个字符。问题是,有时候Erwin附加模式名和表名来约束名。我要忽视这些搜索约束时超过30个字符的名称。例子:我要搜索所有字符串,约束的名字是超过30个字符。如果命名为约束,然后我必须忽略。如果约束的名字,那么我必须忽略..约束的名字总是出现在这是我必须检查的唯一名称。任何帮助将不胜感激。谢谢,

原文:

I am an Oracle DBA and need help with searching using Notepad++. Here is the requirement. I have a huge DDL script generated through Erwin. I want to find out if any constraint name is longer than 30 characters. The problem is that sometimes Erwin appends schema name and table name to the constraint name. I have to ignore these when searching for constraint names longer than 30 characters.

Example:

ALTER TABLE ABC_REPORTING.T_ABCDE_INSPTN_INVESN_SUM_HIST
                ADD CONSTRAINT PK_T_ABCDE_INSPTN_INVSN_SUM_HIST 
                PRIMARY KEY (COL_INSPTN, COL_SEQ_HIST);

I have to search all strings where constraint name PK_T_ABCDE_INSPTN_INVSN_SUM_HIST is longer than 30 characters.

If the constraint is named as ABC.DEF.PK_T_ABCDE_INSPTN_INVSN_SUM_HIST, then I have to ignore ABC.DEF.

If the constraint name is ABC.PK_T_ABCDE_INSPTN_INVSN_SUM_HIST, then I have to ignore ABC..

The constraint name always comes after ADD CONSTRAINT so this is the only name I have to check.

Any help will be appreciated.

Thanks,

解决方案:
这将做你想做的事情,它不会匹配虽然如果你有一个很长的模式或表名(也就是说,要么是30+字符)也会匹配,-他们最后的字符。这个正则表达式并寻找“任何字符(a-z大写或下划线)这不是紧随其后的是一段文字“30次以上。
原文:

This will do what you want

([A-Z_](?!\.)){30,}

It won't match the . although if you have a really long schema or table name (that is, either is 30+ characters) those will match too, minus their last character.

What this regex does is look for "any character (A-Z capitalized or an underscore) that is not followed by a literal period" 30 or more times.

解决方案:
之间所需要的正则表达式是:“是正则表达式的一部分解释说:“找到确切的词。“之后的一个空白,可以出现零个或更多倍。“之后的任何字符点最后,这个群体会出现零次或多次。这是忽略ABC。和美国广播公司(ABC)。DEFABC.BCE。XXX等等。“最后任何字符不同的点或空白,30次以上。记事本正则表达式引用
原文:

The regex you need is:

ADD CONSTRAINT \s*(.+\.)*([^\.\s]{30,})

Between '' is the part of regex to be explained:

'ADD CONSTRAINT' Find the exact word.

'\s*' Followed of a blank, that can appear zero or more times.

'(.+\.)*' Followed of any character with a dot in the end, that group can appear zero or many times. This is for ignore ABC. and ABC.DEF ABC.BCE.XXX and on and on.

'([^\.\s]{30,})' And finally any character different to dot or blank, 30 or more times.

Notepad regex reference

解决方案:
使用(单词字符,包括下划线)来匹配你的名字:会发现所有你寻求的支安打。我添加了如果你有超过30个字符模式名称。
原文:

Use \w (word char, which includes the underscore) to match your name:

ADD CONSTRAINT.*\w{31,}$

will find all the hits you seek. I added the $ in case you have schema names longer than 30 chars.