Want to remove everything after nth “/” from hyperlink in Notepad++ or Excel

前端 未结 2 927
情歌与酒
情歌与酒 2021-01-16 15:37

I need some help: looking for a way to remove everything after the nth occurrence (most likely 4th or 5th) of \"/\" in a hyperlink. For instance, if I have

         


        
2条回答
  •  醉梦人生
    2021-01-16 15:51

    Using Notepad++:

    • Ctrl+H
    • Find what: ^((?:[^/]*/){5}).*$
    • Replace with: $1
    • check Wrap around
    • check Regular expression
    • DO NOT CHECK . matches newline
    • Replace all

    Explanation:

    ^               : begining of lin
      (             : start group 1
        (?:         : start non capture group
          [^/]*     : 0 or more any character that is not a slash
          /         : a slash
        ){5}        : group must appear 5 times
      )             : end group 1
      .*            : 0 or more any character
    $               : end of line
    

    Replacement:

    $1          : content of group 1 (ie. everything before the 5th slash)
    

    Result for given example:

    https://www.forbes.com/forbes/welcome/
    

提交回复
热议问题