# Quoted string (to EOF if unmatched). (\'|")(?:\\\\\\1|[^\\1])*?(?:\\1|$) | # Block comment (to EOF if unmatched). /\\*(?:[^*]*\\*+(?:[^/*][^*]*\\*+)*/|.*) ~xsS'; // Misc. $patt->vendorPrefix = '~^-([a-z]+)-([a-z-]+)~iS'; $patt->ruleDirective = '~^(?:(@include)|(@extends?)|(@name))[\\s]+~iS'; $patt->argListSplit = '~\\s*[,\\s]\\s*~S'; $patt->cruftyHex = Regex::make('~\\#({{hex}})\\1({{hex}})\\2({{hex}})\\3~S'); $patt->token = Regex::make('~^ \\? (?<type>[a-zA-Z]) {{token_id}} \\? $~xS'); } public static function make($pattern) { static $cache = array(); if (isset($cache[$pattern])) { return $cache[$pattern]; } return $cache[$pattern] = preg_replace_callback('~\\{\\{ *(?<name>\\w+) *\\}\\}~S', function ($m) { return Regex::$classes->{$m['name']}; }, $pattern); } public static function matchAll($patt, $subject, $offset = 0) { $count = preg_match_all($patt, $subject, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER, $offset); return $count ? $matches : array(); } } Regex::init();