Batch file 使用工具替换脚本中的specefique代码
我有一个包含随机代码的脚本,但我正在记事本++中寻找一种方法,或者寻找一个批处理文件或任何可以替换sepcifque代码的工具,下面是一个示例:Batch file 使用工具替换脚本中的specefique代码,batch-file,notepad++,Batch File,Notepad++,我有一个包含随机代码的脚本,但我正在记事本++中寻找一种方法,或者寻找一个批处理文件或任何可以替换sepcifque代码的工具,下面是一个示例: Random If this equal that then you soulAd do this and do that therefore.. the code should be executed immediatly --stackb select * from user_error where object_name = name sele
Random
If this equal that then you soulAd do this and do that therefore..
the code should be executed immediatly
--stackb
select * from user_error where object_name = name
select * from user_error where table= randomly
case 1 a = b else c=a
--stacke
Begin with the structure of the data and divide the codes
end with what you know
我想替换注释堆栈b和堆栈a之间的单词,因此结果如下所示
Random
If this equal that then you sould do this and do that therefore..
the code should be executed immediatly
--stackb
The codes here has been replaced,
can you do that ?
case 1 a = b else c=a
--stacke
Begin with the structure of the data and divide the codes
end with what you know
“批处理文件”或“记事本+”中是否有代码可用于获取结果?在“记事本+”中,转到“搜索>替换”菜单(快捷键CTRL+H),然后执行以下操作:
$1replaced text$2
替换所有
Random
If this equal that then you soulAd do this and do that therefore..
the code should be executed immediatly
--stackb
select * from user_error where object_name = name
select * from user_error where table= randomly
case 1 a = b else c=a
--stacke
Begin with the structure of the data and divide the codes
end with what you know
致:
正则表达式解释:
(\-\-stackb.*?)select.+?$\r?\nselect.+?$(\r?\n.*?\-\-stacke)
匹配字符串\-\-stackb
。这里没有什么特别的,除了转义特殊字符的反斜杠。这意味着--stackb
将被解释为文本-
,而不是正则表达式特殊字符-
点*?
匹配任何字符,加上我们激活选项“.matches newline”后的换行符。星号
是一个用于匹配0次或多次的量词。所以*
意味着匹配任何字符或换行符0次或更多次。当一个量词后面跟一个问号*
时,它会使量词不贪婪,这是一个更高级的话题,但简单地说,这就像对量词说,尽量用?
的最小数量来满足自己
现在您已经理解了正则表达式的含义,可以添加括号以捕获匹配结果。您可以使用特殊变量(\-\-stackb.*?
(或$1
相同)访问结果。正如您所看到的,我们正在替换中使用它\1
这里唯一的新东西是select.+?$\r?\n
,它匹配行尾和用于查找换行符的特殊字符$
(回车符),\r
(换行符)。请注意,\n
后面跟着\r
量词,表示匹配1或0次?
--stackb
和--stacke
周围的任何类型的文本,请使用以下命令:find=(\-\-stackb)。+?(\-\-stacke)
,replace=$1\n\nreplace\n\n$2
。
Random
If this equal that then you soulAd do this and do that therefore..
the code should be executed immediatly
--stackb
replaced text
case 1 a = b else c=a
--stacke
Begin with the structure of the data and divide the codes
end with what you know