[英]Delete all lines until a specific line in Notepad++
I have to edit a lot of source codes similar to each other. 我必须编辑很多彼此相似的源代码。
random blah
random blah
blah
<table style="width: 232px; font-size: small;" cellpadding="0" cellspacing="0">....
What I want to do is to delete lines until table tag. 我想要做的是删除行直到表标记。 I think I can do it with Regex search but I couldnt write the regex pattern. 我想我可以用正则表达式搜索来做,但我不能写正则表达式模式。 Thank you 谢谢
You have to go through multiple steps to do what you stated above: 您必须经过多个步骤才能执行上述操作:
Go to the replace window, select the "extended" mode, and in the "find what" field type in " \\r\\n
" and replace them with: " LINEBREAK
" (theres a space after 'LINEBREAK'). 转到替换窗口,选择“扩展”模式,然后在“找到什么”字段中输入“ \\r\\n
”并将其替换为:“ LINEBREAK
”(“ LINEBREAK
”后面的空格)。 Click on replace all. 点击全部替换。
Go to the replace window again, select the "regular expression" mode, and in the "find what" field type in "(.*)(.*)(<table)(.*)(>)(.*)(.*)"
and in the replace with field, type in " \\2\\3\\4\\5
". 再次转到替换窗口,选择“正则表达式”模式,并在“找到什么”字段中输入"(.*)(.*)(<table)(.*)(>)(.*)(.*)"
并在字段替换中输入” \\2\\3\\4\\5
“。 Click on replace all. 点击全部替换。
Now go to replace window again, select elect the "extended" mode, and in the "find what" field type in " LINEBREAK
" (theres a space after 'LINEBREAK') and replace them with: " \\r\\n
". 现在再次更换窗口,选择“扩展”模式,然后在“找到什么”字段中输入“ LINEBREAK
”(“ LINEBREAK
”后面的空格)并将其替换为:“ \\r\\n
”。 Click on replace all. 点击全部替换。
Notepad++ doesn't support multi line regex, which makes it hard to do what you wanted to do without going through the steps given above. Notepad ++不支持多行正则表达式,这使得很难在不经过上面给出的步骤的情况下做你想做的事情。
you can try something like: 你可以尝试类似的东西:
(^.*$\n)*<table(.+)>
First group will match all lines before your table tag %) 第一组将匹配表标记之前的所有行%)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.