A little help please



  • 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!



  • @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.



  • 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!



  • @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”



  • @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.



  • @astrosofista said in A little help please:

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

    …or later!


Log in to reply