2

我正在尝试仅将 GitHub URL 与以下输入标签匹配:

<input type="url" id="repoUrl" title="Must be a full URL to a GitHub repository" pattern="^https:\/\/github\.com\/" required>

在 regex101 中,这个确切的模式匹配所有以“ https://github.com ”开头的字符串,这是我想要的,但问题是当我checkValidity()在该输入上调用该方法时,它只说如果输入是有效的只有https://github.com ”。

我需要改变什么才能使这个正则表达式在 regex101 中工作?

4

1 回答 1

2

尝试.*在模式的末尾添加

pattern="^https:\/\/github\.com\/.*"
于 2020-02-11T19:45:14.703 回答