本文介绍了RegExp首先验证http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个正则表达式来从输入框中删除第一个http.我该怎么办?
I need a regex for removing first http from my input box. how can i do this ?
例如,如果我的输入框的值为 http://welcome.com ,则会删除http://并进行转换到welcome.com
For example if value of my input box is http://welcome.com it remove http:// and convert it to welcome.com
推荐答案
您真的需要正则表达式吗?indexOf()可以完成这项工作:
Do you really need regular expressions?indexOf() can do the job:
function CheckLink()
{
var token = "http://";
var link = "www.example.com";
if(link.indexOf(token)!=0)
link = token + link;
return link;
}
这篇关于RegExp首先验证http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!