Mar-26-2024, 07:08 AM
(This post was last modified: Mar-26-2024, 07:11 AM by Gribouillis.)
(Mar-25-2024, 11:59 PM)Skaperen Wrote: i just want to keep it simple and obvious or well explained in comments.You can simplify it a bit because you don't need to match the 'h'. Here it is with a clear comment
import re # replace any of //, ://, s://, ps://, tps://, ttps:// by https:// at beginning of url url = re.sub(r'^(?:(?:(?:(?:t?t)?p)?s)?\:)?//', 'https://', url)
« We can solve any problem by introducing an extra level of indirection »