开发者

Delete all lines until a specific line in Notepad++

开发者 https://www.devze.com 2023-01-28 09:51 出处:网络
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\">....

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. 开发者_JAVA技巧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:

  1. 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'). Click on replace all.

  2. 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". Click on replace all.

  3. 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". 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.


you can try something like:

(^.*$\n)*<table(.+)>

First group will match all lines before your table tag %)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号