0

i want to split url in embedded url

I've tried Regex, but couldn't do it.

full url

https://docs.google.com/gview?embedded=true&url=https://www.adaletyayinevi.com.tr/image/catalog/icndekiler/9786056403903.pdf&embedded=true

the url i want

https://www.adaletyayinevi.com.tr/image/catalog/icndekiler/9786056403903.pdf

The url address i want may change. Can be for example as follows, but the https and pdf part are always the same

https://www.adaletyayinevi.com.tr/image/icindekiler/9786056403903.pdf

Tolga
  • 46
  • 6
  • What have you tried until now and what is not working? – Vishnudev Krishnadas Apr 11 '23 at 12:55
  • it would be better if you provide your regex too – Gudarzi Apr 11 '23 at 12:55
  • Show what you tried - that is a prerequisite to get help here – ProfDFrancis Apr 11 '23 at 12:56
  • i've tried regex rule, but i'm not good at. example `r = re.split("^https://www.adaletyayinevi.com.tr$pdf", url)` – Tolga Apr 11 '23 at 12:58
  • Regex is a poor choice for this. Consider using urllib instead [Best way to parse a URL query string](https://stackoverflow.com/questions/10113090/best-way-to-parse-a-url-query-string). This would give you a dictionary mapping for direct and easy access. – Chris White Apr 11 '23 at 13:03
  • if i use parse url, returned query `embedded=true&url=https://www.adaletyayinevi.com.tr/image/catalog/icndekiler/9786056403903.pdf&embedded=true` – Tolga Apr 11 '23 at 13:17
  • You could use a regex that is expecting to be a parameter inside the URL, meaning that the url must have an `=` sign before it and must have an `&` or nothing after. Giving you the following regex: `(?<==)http(s)?:\/\/[^&]*` – Logan MacDougall Apr 11 '23 at 13:27

0 Answers0