【问题标题】:How to delete everything before and after the ip address and port? [duplicate]如何删除ip地址和端口前后的所有内容? [复制]
【发布时间】:2021-01-30 03:25:34
【问题描述】:

我想知道如何在 Notepad++ 中删除 IP 地址和端口之前和之后的所有内容。例如,从此:

email:pass | ip = 139.224.45.151 | port = 8080 | protocol = http | country = CN
email:pass | ip = 102.67.68.1 | port = 1080 | protocol = socks4 | country = ZZ
email:pass | ip = 94.54.211.197 | port = 80 | protocol = http | country = TR
email:pass | ip = 161.97.138.241 | port = 3128 | protocol = http | country = US

..到这个

139.224.45.151:8080
102.67.68.1:1080
94.54.211.197:80
161.97.138.241:3128

【问题讨论】:

  • ^.*ip\s*=\s*(\d{1,3}(?:\.\d{1,3}){3})\s*\|\s*port\s*=\s*(\d+).*$ 替换为\1:\2

标签: regex notepad++


【解决方案1】:
  • 找到什么:^.* ip = *([\d\.]*).* port = *(\d*).*$
  • 替换为:$1:$2
  • (o) regular expression 选中,[_] , matches newline 未选中

【讨论】:

    猜你喜欢
    • 2014-03-14
    • 2014-10-21
    • 2021-08-30
    • 1970-01-01
    • 1970-01-01
    • 2010-10-30
    • 2021-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多