Home > OS >  How can I convert this middle-URL string from something (https://m.lala.com/lala/image.png) to somet
How can I convert this middle-URL string from something (https://m.lala.com/lala/image.png) to somet

Time:02-21

Kindly rephrase my question title if something's not right. I tried to be clearer in the title.

Could someone help me replace mass URL strings such as:

https://m.lala.com/lala/yada/yada/someimagename.png

To something like:

https://lolo.com/someimagename.png

Where I could replace the inner URL without changing the "someimagename.png"?

I looking into attempts of writing regex but couldn't do it right.

I attempted https:// [^>] / [^>] .webp to search with regex (inside Notepad ), which seemed to find the URLs but I couldn't replace them the right way as I couldn't hold the value of "someimagename.png"

CodePudding user response:

Try this code ...

Find:^https://\K.*?(?=png)
Replace:lolo.com/someimagename.

CodePudding user response:

You can use groups to hold the value, using (), and use \1 in the replace part, for example:

  • Search: https://[^/] /(.*)\.png
  • Replace: https://something/else/\1.png

\1 will contain the first value inside () and if you use more, the second will be in \2 etc.

  • Related