my regex seems to work fine in regex101 but not in my userscript…
- User
my regex seems to work fine in regex101 but not in my userscript
[\w-]+(?:.[\w-]+)*@[A-Za-z0-9]+(?:.[A-Za-z]{2,})+
// ==UserScript== // @name Email Scraper // @namespace http://tampermonkey.net/ // @version 0.1 // @description Prints emails into the console found in a page // @author brrt // @match :///* // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com // @grant none // ==/UserScript==
(function() { 'use strict';
// Define your regular expression here (in the format /yourRegex/): const regex = /[\w-]+(?:\.[\w-]+)*@[A-Za-z0-9]+(?:\.[A-Za-z]{2,})+/gi; // Recursive function to search for matching strings in the DOM function searchDOM(element, result) { element.childNodes.forEach(function(node) { if (node.nodeType === Node.TEXT_NODE && regex.test(node.textContent)) { // Found a match, add to the result array result.push(node.textContent); } else if (node.nodeType === Node.ELEMENT_NODE) { // Recursively search child elements searchDOM(node, result); } }); } // Start the search from the document’s root element const result = []; searchDOM(document.documentElement, result); // Concatenate the matched strings with new lines const output = result.join('\n'); // Output the concatenated strings to the console console.log(output);})();
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.