Notepad++ 将文本文件中的行重新格式化为命令行参数行 -k "line1" -k "line2" -k "line3"?
Notepad++ Reformat lines in a text file to command line arguments line -k "line1" -k "line2" -k "line3"?
所以我有这样的大文本文件:
Aids
Cancer
Heart Disease
Dwarfism
Coranavirus
基本上,我需要转换它,以便我的命令行脚本可以将它们读取为参数。格式是 -k "keyword" 特别是我需要使用 Notepad++ 重新格式化它 -k "Aids" -k "Cancer" -k "Heart Disease" -k "Dwarfism" -k "Coranavirus"
我该怎么做呢?
我试过使用 ^ 和 \1 表达式将 -k " 放在前面并替换,但我不确定我需要做什么表达式才能将它们全部放在同一行上。
感谢您的帮助。复活节快乐!
- Ctrl+H
- 查找内容:
(.+)\R
- 替换为:
-k ""
- 检查 环绕
- 检查 正则表达式
- 取消选中
. matches newline
- 全部替换
解释:
(.+) # group 1, 1 or more any character but newline
\R # any kind of linebreak (i.e. \r, \n, \r\n)
替换:
-k # literally -k followed by a space
"" # content of group 1 suround by quotes followed by a space
屏幕截图(之前):
截图(后):
所以我有这样的大文本文件:
Aids
Cancer
Heart Disease
Dwarfism
Coranavirus
基本上,我需要转换它,以便我的命令行脚本可以将它们读取为参数。格式是 -k "keyword" 特别是我需要使用 Notepad++ 重新格式化它 -k "Aids" -k "Cancer" -k "Heart Disease" -k "Dwarfism" -k "Coranavirus"
我该怎么做呢?
我试过使用 ^ 和 \1 表达式将 -k " 放在前面并替换,但我不确定我需要做什么表达式才能将它们全部放在同一行上。
感谢您的帮助。复活节快乐!
- Ctrl+H
- 查找内容:
(.+)\R
- 替换为:
-k ""
- 检查 环绕
- 检查 正则表达式
- 取消选中
. matches newline
- 全部替换
解释:
(.+) # group 1, 1 or more any character but newline
\R # any kind of linebreak (i.e. \r, \n, \r\n)
替换:
-k # literally -k followed by a space
"" # content of group 1 suround by quotes followed by a space
屏幕截图(之前):
截图(后):