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



  • 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.


  • @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



  • 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.



  • @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



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



  • 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.


Log in to reply