I have the following strings
http://example.com https://example.com http://www.example.com
how do i get rid of the http://
or https://
?
First you need to parse the tag. Next try to extract st_url value which is your url. Then use a loop from the last character of the extracted url and omit them until you see a '/'. This is how you should extract what you want.
sub(r'http\S+', '', my_string) . The re. sub() method will remove any URLs from the string by replacing them with empty strings.
Try with this:
var url = "https://site.com"; var urlNoProtocol = url.replace(/^https?\:\/\//i, "");
You can use the URL object like this:
const urlWithoutProtocol = new URL(url).host;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With