HTMLPurifier_AttrDef_HTML_Nmtokens::split PHP Метод

split() защищенный Метод

Splits a space separated list of tokens into its constituent parts.
protected split ( string $string, HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : array
$string string
$config HTMLPurifier_Config
$context HTMLPurifier_Context
Результат array
    protected function split($string, $config, $context)
    {
        // OPTIMIZABLE!
        // do the preg_match, capture all subpatterns for reformulation
        // we don't support U+00A1 and up codepoints or
        // escaping because I don't know how to do that with regexps
        // and plus it would complicate optimization efforts (you never
        // see that anyway).
        $pattern = '/(?:(?<=\\s)|\\A)' . '((?:--|-?[A-Za-z_])[A-Za-z_\\-0-9]*)' . '(?:(?=\\s)|\\z)/';
        // look ahead for space or string end
        preg_match_all($pattern, $string, $matches);
        return $matches[1];
    }

Usage Example

Пример #1
0
 protected function split($string, $config, $context)
 {
     // really, this twiddle should be lazy loaded
     $name = $config->getDefinition('HTML')->doctype->name;
     if ($name == "XHTML 1.1" || $name == "XHTML 2.0") {
         return parent::split($string, $config, $context);
     } else {
         return preg_split('/\\s+/', $string);
     }
 }
All Usage Examples Of HTMLPurifier_AttrDef_HTML_Nmtokens::split
HTMLPurifier_AttrDef_HTML_Nmtokens