Regex to test if string begins with http:// or https://

后端 未结 9 916
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 06:41

I\'m trying to set a regexp which will check the start of a string, and if it contains either http:// or https:// it should match it.

How c

9条回答
  •  情深已故
    2020-12-04 07:24

    Case insensitive:

    var re = new RegExp("^(http|https)://", "i");
    var str = "My String";
    var match = re.test(str);
    

提交回复
热议问题