networking - How to delete everything till a ipaddress in notepad++

08
2014-07
  • Diederik

    I have been searching here for the right regex, I have successfully deleted a lot already, but now I get stuck. Here an example:

    25.05.2014 p=161 i=10.0 i=56.0 ip=77.66.38.98
    P      p=25.05.2014 p=161 
    55.0 i=10.0 ip=187.14.83.131
    =1871483131....p4.1.2 
    25.05.2014 p=161 i=79.4272 i=43.7054 ip=192.40.36.12
    P P   (4.1.0 P6.1.3 Pp_05__613.i 16.0.9 
    1p_05_p2_609.i P8853 02  5121806897 04272012)  
    25.05.2014 p=161 i=116.3883 i=39.9289 ip=202.108.242.145
    

    I got another 24000 lines like this.

    I would like to replace everything with nothing except ip=xxx.xxx.xxx.xxx

    So for example with the above code, the output should look like this:

    ip=77.66.38.98
    ip=187.14.83.131
    ip=192.40.36.12
    ip=202.108.242.145
    
  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    regex - Match and delete in Notepad++
  • Questioner

    I have the following text in Notepad++.

    192.168.0.1 37 ms N/A
    192.168.0.2 Dead N/S
    192.168.0.3 Dead N/S
    192.168.0.100 37 ms N/A

    How do I do a find and replace that matches "Dead" and eliminates the line with output like the following?

    192.168.0.1 37 ms N/A
    192.168.0.100 37 ms N/A

    I have tried to use the regular expression ^.*Dead.*$ that does remove the lines, but it doesn't delete the empty spaces.


  • Related Answers
  • manojlds

    You can use two steps:

    Use regex to replace matches for ^.*Dead.*$ with markedfordel

    Then in extended mode, for matches of markedfordel\r\n replace with empty

    Screenshot:

    enter image description here

  • stema

    Go to the search then to the Mark tab, enter "Dead", check "mark line" and click "Find all". It results in bookmarks for all those lines.

    In the search menu there is a point "delete bookmarked lines"

  • Christian Jonassen

    Combine/enhance/replace your regex with the solutions here: http://superuser.com/questions/35233/delete-blank-lines-from-a-text-file

  • Francis Gilbert

    Try a Regex replace in Notepad++ with:

    (.*)Dead(.*)
    

    That'll remove the lines for you.

  • Ben Richards

    You can use your first step to blank the lines that contain "Dead" in them, and then what I usually do is use one of the plugins typically included with Notepad++ to remove blank lines. To do that, I press Ctrl+A to highlight the entire document, then go to the TextFX menu (for the TextFX plugin), go to TextFX Edit, and then select Delete Blank Lines (about halfway down the menu). That will, as it said, remove all blank lines in the highlighted region.