如何解决删除 URL 开头的字符串
取决于你需要什么,你有几个选择,你可以这样做:
// this will replace the first occurrence of "www." and return "testwww.com"
"www.testwww.com".replace("www.", "");
// this will slice the first four characters and return "testwww.com"
"www.testwww.com".slice(4);
// this will replace the www. only if it is at the beginning
"www.testwww.com".replace(/^(www\.)/,"");
解决方法
我想www.
从 URL 字符串的开头删除“”部分
例如在这些测试用例中:
eg www.test.com
——eg —— test.com
eg www.testwww.com
—— testwww.com
eg testwww.com
—— testwww.com
(如果不存在的话)
我需要使用正则表达式还是有智能功能?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。