• Login
Community
  • Login

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

Scheduled Pinned Locked Moved General Discussion
6 Posts 3 Posters 2.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    dkseby7x
    last edited by Feb 14, 2021, 9:57 PM

    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 Reply Last reply Reply Quote 0
    • T
      Terry R
      last edited by Feb 14, 2021, 10:18 PM

      @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 Reply Last reply Reply Quote 1
      • D
        dkseby7x
        last edited by dkseby7x Feb 14, 2021, 10:24 PM Feb 14, 2021, 10:22 PM

        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 Reply Last reply Reply Quote 1
        • T
          Terry R
          last edited by Terry R Feb 14, 2021, 10:34 PM Feb 14, 2021, 10:33 PM

          @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 Reply Last reply Reply Quote 2
          • D
            dkseby7x
            last edited by Feb 14, 2021, 10:43 PM

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

            1 Reply Last reply Reply Quote 1
            • P
              prahladmifour
              last edited by Feb 16, 2021, 4:26 AM

              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 Reply Last reply Reply Quote -1
              1 out of 6
              • First post
                1/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors