Перейти к основному содержимому
claw
am
tools
Инструменты
Документы
Daoark
EN
Главная
Главная
/
Текстовые инструменты
›
]+/g }, idcard: { name: '[ID] 身份证号', re: /[1-9]\d{5}(?:18|19|20)\d{2}(?:0\d|1[0-2])(?:[0-2]\d|3[01])\d{3}[\dXx]/g }, ip: { name: '[IP] IP 地址', re: /(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)/g } }; form.addEventListener('submit', function(e) { e.preventDefault(); clearError(); clearResult(); var text = document.getElementById('text').value; if (!text.trim()) { showError('请输入文本'); return; } var dedup = document.getElementById('dedup').checked; var html = ''; var summary = []; for (var key in PATTERNS) { var cb = document.getElementById('ex_' + key); if (!cb || !cb.checked) continue; var matches = text.match(PATTERNS[key].re) || []; if (dedup) matches = Array.from(new Set(matches)); if (matches.length === 0) { summary.push(PATTERNS[key].name + ': 0'); continue; } summary.push(PATTERNS[key].name + ': ' + matches.length); html += '
' + PATTERNS[key].name + ' (' + matches.length + ')
' + matches.map(escapeHtml).join('\n') + '
Copiar
'; } if (!html) { showError('未勾选任何类型, 或文本中无匹配项'); return; } resultContent.innerHTML = html; resultMeta.textContent = summary.join(' | ') + ' | 文本长度: ' + text.length; resultArea.classList.add('show'); // 复制按钮 resultArea.querySelectorAll('button[data-copy]').forEach(function(b) { b.addEventListener('click', function() { navigator.clipboard.writeText(JSON.parse(b.dataset.copy)).then(function() { b.textContent = '已复制'; setTimeout(function() { b.textContent = '复制'; }, 1000); }); }); }); }); function escapeHtml(s) { return s.replace(/&/g, '&').replace(//g, '>'); } btnClear.addEventListener('click', function() { form.reset(); document.getElementById('ex_phone').checked = true; document.getElementById('ex_email').checked = true; document.getElementById('ex_url').checked = true; document.getElementById('ex_idcard').checked = false; document.getElementById('ex_ip').checked = false; document.getElementById('dedup').checked = true; clearError(); clearResult(); }); })();