Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想要一个与 http 或 https 匹配的字符串的简单正则表达式。我开始:
#^((http|https)://)"
它不起作用。我希望 :// 也在开头,所以我放了双括号。我在正则表达式方面有点新手。希望你能帮助我。
尝试
https?:\/\/
意义:
http - required: "http" s? - followed by an optional "s" :\/\/ - followed by required "://"
我认为您正在寻找?可选的运算符:
?
/^(https?)?:\/\//
这使得safterhttp和整个组都是可选的,也允许字符串直接以开头://。
s
http
://