How do I write a regular expression?
The page has fields with value = there are several of them, one of them is responsible for mail, I need to parse the page with a get request and pull out exactly the mail, how to do this, I tried many options, it still does not work to cut off the code after the mail b>
Don't suffer with regulars. Yuzai DOM:
const html = `<td>
<input type="text" name="email" id="email" class="required email" value="[email protected]" />
const template = document.createElement('template')
template.innerHTML = html
console.log(template.content.querySelector('input[name="email"]').value) // [email protected]Anonymous
If you need regulars - this is how you can
let m= document.body.innerHTML.match(/(?=[^>]*name="email")<input[^>]+value="([^"]+)"/is);
Regular of 2 halves. The second one defines an element and picks out its value, the first one checks that the name of this element is correct. The expectation is that the quotes will always be double.
Through the House, of course, is better. You don't have to put quotes around.Isabella Skinner
To place the code, please use CodePen or similar tool. Thanks you!