<!DOCTYPE html>
<html>
<head>
<title>批量匹配链接</title>
<meta charset="UTF-8">
<script>
function matchLinks() {
// 获取输入框内容
var input = document.getElementById("input");
var text = input.value;
// 匹配链接
var regex = /https?:\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/g;
var matches = text.match(regex);
// 输出匹配结果
if (matches) {
input.value = matches.join("\n");
} else {
input.value = "没有匹配到链接。";
}
}
</script>
</head>
<body>
<h1>批量匹配链接</h1>
<p>输入文本:</p>
<textarea id="input" rows="10"></textarea>
<br>
<button onclick="matchLinks()">匹配链接</button>
</body>
</html>