【问题标题】:Notepad++ Directory ReplacingNotepad++ 目录替换
【发布时间】:2021-05-22 02:16:59
【问题描述】:

我需要一些帮助 我有一个这样的网址 https://developers.apple.com/forums/profile/ShadowDES/Boy?view=FUZZ

我想要的是用特定的关键字替换每个目录,即 XYZ

https://developers.apple.com/XYZ/profile/ShadowDES/Boy?view=32
https://developers.apple.com/forums/XYZ/ShadowDES/Boy?view=32
https://developers.apple.com/forums/profile/XYZ/Boy?view=32

表示如果有 3 个目录,输出应该是 3 个 urls

我有一个网址列表,有什么办法可以做到吗?

【问题讨论】:

    标签: notepad++


    【解决方案1】:

    这适用于最多包含 5 个目录的 URL。如果超过 5 个,请根据需要添加尽可能多的 (.+?/)?,并相应地更新替换中的组号。

    • Ctrl+H
    • 查找内容:(https?://.+?/)(.+?/)(.+?/)?(.+?/)?(.+?/)?(.+?/)?(\S+)
    • 替换为:$1XYZ/$3$4$5$6$7\n(?3$1$2XYZ/$4$5$6$7\n)(?4$1$2$3XYZ/$5$6$7\n)(?5$1$2$3$4XYZ/$6$7\n)(?6$1$2$3$4$5XYZ/$7)
    • 检查 环绕
    • CHECK 正则表达式
    • 取消选中 . matches newline
    • 全部替换

    说明:

    (https?://.+?/)     # group 1, domain, 1 or more any character but newline, not greedy & slash
    (.+?/)              # group 2, 1rst dir, 1 or more any character but newline, not greedy & slash
    (.+?/)?             # optional group 3, 2nd dir, 1 or more any character but newline, not greedy & slash
    (.+?/)?             # same for group 4
    (.+?/)?             # same for group 5
    (.+?/)?             # same for group 6
    (\S+)               # group 7, rest of the URL
    

    替换:

    $1XYZ/$3$4$5$6$7\n          # replace group 2 (1rst dir) with XYZ
    (?3$1$2XYZ/$4$5$6$7\n)      # if group 3 exists, replace group 3 (2nd dir) with XYZ
    (?4$1$2$3XYZ/$5$6$7\n)      # if group 4 exists, replace group 4 (3rd dir) with XYZ
    (?5$1$2$3$4XYZ/$6$7\n)      # if group 5 exists, replace group 5 (4th dir) with XYZ
    (?6$1$2$3$4$5XYZ/$7)        # if group 6 exists, replace group 6 (5th dir) with XYZ
    

    屏幕截图(之前):

    截图(之后):

    【讨论】:

    • 你真是个记事本专业人士,它对我有很大帮助
    • @HelloFresh01:不客气,很高兴它有帮助。随意将答案标记为已接受,How to accept an answer
    猜你喜欢
    • 2011-11-28
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    • 2017-01-27
    • 2010-12-23
    • 2014-12-26
    • 2012-09-14
    • 2012-04-01
    相关资源
    最近更新 更多