英文:
I want to extract all occurring text between "CREATE INDEX" and ")" on the following text
问题
我要提取以下文本:
CREATE INDEX "SCHEMA"."INDEX_NAME1" ON "SCHEMA"."TABNAME1"
("COLX" ASC)
CREATE INDEX "SCHEMA"."INDEX_NAME2" ON "SCHEMA"."TABNAME2"
("COL1" ASC,
"COL2" ASC)
然后,您可以将这段提取的文本复制到另一个文本文件中或进行其他必要的操作。
英文:
I have a text looking like this. But there are thousands of lines to the text. I want to extract text from this and only get the index data.
CREATE INDEX "SCHEMA"."INDEX_NAME1" ON "SCHEMA"."TABNAME1"
("COLX" ASC)
COMPRESS NO
INCLUDE NULL KEYS ALLOW REVERSE SCANS;
-- DDL Statements for Indexes on Table "CBLOSUAT"."KCR_PRODUCT"
SET SYSIBM.NLS_STRING_UNITS = 'SYSTEM';
CREATE INDEX "SCHEMA"."INDEX_NAME2" ON "SCHEMA"."TABNAME2"
("COL1" ASC,
"COL2" ASC)
COMPRESS NO
INCLUDE NULL KEYS ALLOW REVERSE SCANS;
I want something like
CREATE INDEX "SCHEMA"."INDEX_NAME1" ON "SCHEMA"."TABNAME1"
("COLX" ASC)
CREATE INDEX "SCHEMA"."INDEX_NAME2" ON "SCHEMA"."TABNAME2"
("COL1" ASC,
"COL2" ASC)
I am getting the text by using "CREATE INDEX[^;]+;" in search mode but now I want to select all of the code and copy it to another text file or create a new text file or delete the rest of the code while keeping what I want.
答案1
得分: 1
- <kbd>Ctrl</kbd>+<kbd>H</kbd>
- 查找内容:
^\h*CREATE INDEX.+?\(.+?\)\R(*SKIP)(*FAIL)|.
- 替换为:
LEAVE EMPTY
- TICK 环绕
- SELECT 正则表达式
- TICK
. 匹配换行
- <kbd>全部替换</kbd>
英文:
- <kbd>Ctrl</kbd>+<kbd>H</kbd>
- Find what:
^\h*CREATE INDEX.+?\(.+?\)\R(*SKIP)(*FAIL)|.
- Replace with:
LEAVE EMPTY
- TICK Wrap around
- SELECT Regular expression
- TICK
. matches newline
- <kbd>Replace all</kbd>
Explanation:
^ # beginning of line
\h* # 0 or more horizontal spaces
CREATE INDEX # literally
.+? # 1 or more any character, not greedy
\( # opening parenthesis
.+? # 1 or more any character, not greedy
\) # closing parenthesis
\R # any kind of linebreak
(*SKIP) # forget this match
(*FAIL) # and considere the match has failed
| # OR
. # any character
Screenshot (before):
Screenshot (after):
答案2
得分: 0
我首先在正则搜索模式中使用了"CREATE INDEX[^;]+\Q)\E"来找到答案,然后从Notepad++提供的选项中标记并复制它。
英文:
I found the answer by the way. I first used "CREATE INDEX[^;]+\Q)\E" in the regex search mode. Then marked it and copy it from the options provided by the notepad++
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论