Posts Tagged: "xhtml"

How to do a RegEx match open tags except XHTML self-contained tags

To match open HTML tags but exclude self-closing XHTML tags using Regular Expressions (RegEx), you can use the following pattern: RegEx Pattern <([a-zA-Z][a-zA-Z0-9]*)(?![^>]*\/>)> Explanation of the Pattern Example HTML Snippet <div> <img src="image.jpg" /> <input type="text" /> <span>Text</span> <br /> <p>Paragraph</p></div> Matches Using the RegEx <([a-zA-Z][a-zA-Z0-9]*)(?![^>]*\/>)>: Code Example JavaScript Example const html = `<div> <img […]