• Login
Community
  • Login

A little help please

Scheduled Pinned Locked Moved General Discussion
6 Posts 3 Posters 352 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K
    Kathy Medina
    last edited by Jan 14, 2021, 4:31 PM

    Im using notepad to try something
    i have a lot of trext like this:

    <host endtime=“1610639975”><address addr=“179.8.138.90” addrtype=“ipv4”/><ports><port protocol=“tcp” portid=“37777”><state state=“open” reason=“syn-ack” reason_ttl=“60”/></port></ports></host>
    <host endtime=“1610639976”><address addr=“201.217.248.199” addrtype=“ipv4”/><ports><port protocol=“tcp” portid=“37777”><state state=“open” reason=“syn-ack” reason_ttl=“52”/></port></ports></host>
    <host endtime=“1610639977”><address addr=“190.82.98.90” addrtype=“ipv4”/><ports><port protocol=“tcp” portid=“37777”><state state=“open” reason=“syn-ack” reason_ttl=“56”/></port></ports></host>
    <host endtime=“1610639977”><address addr=“201.217.253.232” addrtype=“ipv4”/><ports><port protocol=“tcp” portid=“37777”><state state=“open” reason=“syn-ack” reason_ttl=“54”/></port></ports></host>

    and i need to delete everything and just leave the ips
    like this:
    179.8.138.90
    201.217.248.199
    190.82.98.90
    201.217.253.232

    im a newbi on this, and im trying to do this with the “replace” option.

    thanks friends!

    A A 2 Replies Last reply Jan 14, 2021, 6:20 PM Reply Quote 0
    • A
      Alan Kilborn @Kathy Medina
      last edited by Jan 14, 2021, 6:20 PM

      @Kathy-Medina

      I’m sure there are “tighter” ways to match IP addresses, but I’d probably do this with your data:

      Open the Mark dialog by pressing Ctrl+m

      find: \d{1,3}(?:\.\d{1,3}){3}
      search mode: regular expression

      Press the Mark all button.

      This should mark in a color (usually reddish) your IPs.

      Press the Copy Marked Text button and then do a paste somewhere else. There’s your data.

      1 Reply Last reply Reply Quote 4
      • A
        astrosofista @Kathy Medina
        last edited by Jan 14, 2021, 6:22 PM

        Hi @Kathy-Medina

        I assume that the curly quotes in the data you posted are actually straight quotes. If that is the case, then the following regex will do the job:

        Search: (?-s).*?addr="([\d.]+)".*?|.*
        Replace: $1
        

        Put the caret at the very beginning of the document, select just the Regular Expressions mode and click the Replace All button.

        Take care and have fun!

        1 Reply Last reply Reply Quote 4
        • K
          Kathy Medina
          last edited by Jan 14, 2021, 7:08 PM

          @astrosofista said in A little help please:

          $1

          great!
          thanks a lot

          the replace method works for me.
          About the Alans Method, a can t find the option “copy marked text”

          A 1 Reply Last reply Jan 14, 2021, 7:31 PM Reply Quote 1
          • A
            astrosofista @Kathy Medina
            last edited by Jan 14, 2021, 7:31 PM

            @Kathy-Medina said in A little help please:

            copy marked text

            You’re welcome. To take advantage of the “copy marked text” option you need v7.9.1.

            A 1 Reply Last reply Jan 14, 2021, 7:34 PM Reply Quote 1
            • A
              Alan Kilborn @astrosofista
              last edited by Jan 14, 2021, 7:34 PM

              @astrosofista said in A little help please:

              To take advantage of the “copy marked text” option you need v7.9.1.

              …or later!

              1 Reply Last reply Reply Quote 1
              2 out of 6
              • First post
                2/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors