Community
    • 登入

    How to remove text except urls mantaining the original line of the remove ?

    已排程 已置頂 已鎖定 已移動 General Discussion
    6 貼文 3 Posters 2.1k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • D
      dkseby7x
      最後由 編輯

      Hi all, I’ve a question, how can I do as title said ? I’ve read about the replace function but how to do with this example one:
      12012 - Another Direction https://anilist.co/activity/171750214
      12012 - Cyclone https://anilist.co/activity/171746802
      Also in the list there are other than numbers one, but i have only to remove all the text and if possible mantain their original line like:

      1. 12012 - Another Direction https://anilist.co/activity/171750214
        and as result
      2. remaining only the link in the same line without deleting space, because others doesn’t have one, have a long list one.
        Thank you in advice.
      1 條回覆 最後回覆 回覆 引用 0
      • Terry RT
        Terry R
        最後由 編輯

        @dkseby7x said in How to remove text except urls mantaining the original line of the remove ?:

        but i have only to remove all the text and if possible mantain their original line like:

        Your question is confusing. Please enter a few examples, select them in the window where you type them and then select the </> button. this will place the examples in a black box (see my example below). Then copy those examples, paste them again and edit them to show what you want to see after changes made. Again select them and hit the </> button to put them into a second black box.

        12012 - Another Direction https://anilist.co/activity/171750214
        and as result
        remaining only the link in the same line without deleting space, because others doesn’t have one, have a long list one.
        

        The black box allows us to see what the original text is like, just in case the data includes characters the markdown system uses when posting your question.

        Terry

        1 條回覆 最後回覆 回覆 引用 1
        • D
          dkseby7x
          最後由 dkseby7x 編輯

          Sorry, I’ll fix it:
          Original one:

          12012 - Another Direction  https://anilist.co/activity/171750214
          12012 - Cyclone https://anilist.co/activity/171746802
          12012 - Deicida of silence
          

          Desired one result:

          https://anilist.co/activity/171750214
          https://anilist.co/activity/171746802
          "remaining empthy line"
          

          Like remove all the text, and also keeping the position of lines.

          1 條回覆 最後回覆 回覆 引用 1
          • Terry RT
            Terry R
            最後由 Terry R 編輯

            @dkseby7x said in How to remove text except urls mantaining the original line of the remove ?:

            Like remove all the text, and also keeping the position of lines

            Thanks for using the black boxes and showing the result you want. It makes it much clearer to understand.
            I have a regex (regular expression) which works on your 3 example lines. So using the Replace function we have
            Find What:(?-s)^.+?(https://.+)*$
            Replace With:\1
            As this is a regex the search mode MUST be “regular expression”. Wrap around should be ticked (in case you aren’t on the first line of the file when using the replace function, it wraps around so the whole file is processed).
            The red text above can be copied and inserted into the relevant fields and then you can either repeatedly push “Replace” button if wanting to see the changes one at a time or the “Replace All” button to process the whole file.

            Terry

            1 條回覆 最後回覆 回覆 引用 2
            • D
              dkseby7x
              最後由 編輯

              Thanks a lot, working very well, you saved my day, thank you again.

              1 條回覆 最後回覆 回覆 引用 1
              • prahladmifourP
                prahladmifour
                最後由 編輯

                Hello,@dkseby7x
                Please try this code, To How to remove text except URLs maintaining the original line of the remove?

                search for:

                \h*<url\b.*?(http[^<]+).*?</url>|<.*?>\s*
                

                and replace with captured URL (captured in the first parenthesized group)

                \1
                

                \h matches any horizontal space, [^<]+ matches one or more characters, that are not <

                I hope this code will be useful to you.
                Thank you.

                1 條回覆 最後回覆 回覆 引用 -1
                • 第一個貼文
                  最後的貼文
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors