Latest Blog Post

Regex for unbalanced anchor tag

Here is a regex expression for finding an unbalanced anchor tag in a chunk of text

<?php
if (preg_match_all('/<a\b[^>]*>(.*?)(?!<\/a>)/', $markup)) {
  // We found one or more, do something
}  

Portfolio

Valid XHTML 1.0 Transitional