Beispiel #1
0
 public static function getRegexTags($tags, $include_no_attributes = true, $include_ending = true, $required_attributes = array())
 {
     require_once __DIR__ . '/text.php';
     $tags = nnText::toArray($tags);
     $tags = count($tags) > 1 ? '(?:' . implode('|', $tags) . ')' : $tags['0'];
     $spaces = self::getRegexSpaces();
     $attribs = $spaces . '[^>"]*(?:"[^"]*"[^>"]*)+';
     $required_attributes = nnText::toArray($required_attributes);
     if (!empty($required_attributes)) {
         $attribs = $spaces . '[^>"]*(?:"[^"]*"[^>"]*)*(?:' . implode('|', $required_attributes) . ')\\s*=\\s*(?:"[^"]*"[^>"]*)+';
     }
     if ($include_no_attributes) {
         $attribs = '(?:' . $attribs . ')?';
     }
     if (!$include_ending) {
         return '<' . $tags . $attribs . '>';
     }
     return '<(?:\\/' . $tags . '|' . $tags . $attribs . ')(?:\\/|' . $spaces . ')*>';
 }