用于检查 URL 是否为 URL 的正则表达式
Regular expression to check if the URL is home URL or not
我正在寻找一个正则表达式来检查 URL 是否在家 URL。
有效
http://example.com
https://example1.com
https://example2.com/
http://anything.com/?test=12
http://anything.com?test=12
无效
http://example.com/path
https://example.com/path1/path2
https://example.com/path1?test=123
您可以使用这个正则表达式:
/^https?:\/\/[^\/]+\/?(\?.*)?$/gm
我正在寻找一个正则表达式来检查 URL 是否在家 URL。
有效
http://example.com
https://example1.com
https://example2.com/
http://anything.com/?test=12
http://anything.com?test=12
无效
http://example.com/path
https://example.com/path1/path2
https://example.com/path1?test=123
您可以使用这个正则表达式:
/^https?:\/\/[^\/]+\/?(\?.*)?$/gm