简体   繁体   English

用记事本++正则表达式清除html

[英]clear html with notepad++ regex

I would want to replace obsolete html head codes with newer ones with the help of notepad++ regex. 我想在notepad ++ regex的帮助下用更新的html头代码替换过时的html头代码。

I can't figure it out how to select multiple rows and how to find strings from the beginning of the file until the tag. 我无法弄清楚如何选择多行以及如何从文件的开头直到标记查找字符串。 Then in the next search&replace I would like to replace the text between to 然后在下一次搜索和替换我想替换之间的文本

Have tried the following and others with no avail: 尝试了以下和其他没有用的:

(.*)<title>
</title>(.*)</head>

Seems to me that it would search only for strings in one line. 在我看来,它只搜索一行中的字符串。

Thanks for helping me out! 谢谢你的协助!

*I am using Notepad++ V6.1.6 *我使用的是Notepad ++ V6.1.6

图片

As said before, in the find dialog you must check the options regular expression option and matches newline if you want to achieve what you say. 如前所述,在查找对话框中,您必须检查选项regular expression选项并matches newline如果您想实现您所说的。

You can also achieve the same effect without checking ". mathces new line" box by adding (?s) in front of the regular expression (that will enable DOTALL mode). 您也可以通过在正则表达式前添加(?s) (将启用DOTALL模式)来检查“.cysces new line”框来实现相同的效果。 Also you can use (?-s) in front of the expresssion to disable DOTALL mode while either ". mathces new line" is checked or DOTALL mode has been enabled by (?s) modifier. 您还可以在expresssion前面使用(?-s)来禁用DOTALL模式,同时选中“.cysces new line”或者通过(?s)修饰符启用DOTALL模式。 This can be useful when you want to enable or disable DOTALL mode inside the regex. 当您想要在正则表达式中启用或禁用DOTALL模式时,这非常有用。 For example the following regex will find both stream and block comments in PHP code: 例如,以下正则表达式将在PHP代码中找到流和块注释:

(?s)/\*.*?\*/|//(?-s).*

Just check the box . matches new line 只需勾选方框即可. matches new line . matches new line in the search/replace window. . matches new line搜索/替换窗口. matches new line

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM