taking off the http or https off a javascript string

前端 未结 12 1632
面向向阳花
面向向阳花 2020-12-20 11:23

I have the following strings

http://example.com
https://example.com
http://www.example.com

how do i get rid of the http:// or

12条回答
  •  余生分开走
    2020-12-20 12:04

    Try with this:

    var url = "https://site.com";
    var urlNoProtocol = url.replace(/^https?\:\/\//i, "");
    

提交回复
热议问题