<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>批量提取strong标签和data-url内容示例</title>
</head>
<body>
<h3>输入文本框:</h3>
<textarea id="inputText" rows="6" cols="50"></textarea>
<br>
<button onclick="extractData()">点击提取</button>
<h3>输出文本框:</h3>
<textarea id="outputText" rows="6" cols="50"></textarea>
<script>
function extractData() {
var inputText = document.getElementById("inputText").value;
var strongRegex = /<strong>(.*?)<\/strong>/g;
var urlRegex = /data-url="(.*?)"/g;
var strongMatches = inputText.matchAll(strongRegex);
var urlMatches = inputText.matchAll(urlRegex);
var results = "";
for (const match of strongMatches) {
results += match[1] + "\n";
}
for (const match of urlMatches) {
results += match[1] + "\n";
}
document.getElementById("outputText").value = results;
}
</script>
</body>
</html>