解析日期或时间的格式串
@param string $pattern
@return array
975012
static protected function analysisPattern($pattern)
    {
        if (!($n = self::$_mbstringAvailable ? mb_strlen($pattern, APP_CHARSET) : strlen($pattern))) {
            return [];
        }
        $ps = [];
        $c0 = self::$_mbstringAvailable ? mb_substr($pattern, 0, 1, APP_CHARSET) : substr($pattern, 0, 1);

        for ($start = 0, $i = 1; $i < $n; ++$i) {
            $c = self::$_mbstringAvailable ? mb_substr($pattern, $i, 1, APP_CHARSET) : substr($pattern, $i, 1);
            if ($c !== $c0) {
                $ps[] = self::$_mbstringAvailable ? mb_substr($pattern, $start, $i - $start, APP_CHARSET) : substr($pattern, $start, $i - $start);
                $c0 = $c;
                $start = $i;
            }
        }
        $ps[] = self::$_mbstringAvailable ? mb_substr($pattern, $start, $n - $start, APP_CHARSET) : substr($pattern, $start, $n - $start);
        return $ps;
    }
640145
private function _getRandAddressCode($pattern)
    {
        $keys = array_keys($this->_addressCodeList);
        $result = preg_grep($pattern, $keys);

        return $result[array_rand($result)];
    }
615614
protected function getFilesByPattern($pattern)
    {
        $iterator = Injector::inst()->create('GreenFinder')
            ->in($this->getPath())
            ->name($pattern);
        $files = [];

        foreach ($iterator as $file) {
            $files[] = $this->getRelativePath() . '/' . $file->getRelativePathname();
        }

        return $files;
    }
32731
private function getMethods($pattern = "/^action_/") {
		$methos = get_class_methods($this->class);
		$actions = array();

		foreach ($methos as $methodName) {
			if (preg_match($pattern, $methodName)) {
				array_push($actions, $methodName);
			}
		}
		return $actions;
	}
276083
public function keys($pattern)
    {
        $keys = $this->getDriver()->keys($pattern);

        if ($this->hasMaxSize()) {
            foreach ($keys as $index => $key) {
                if ($this->isMappedKey($key)) {
                    unset($keys[$index]);
                }
            }
        }
        return $keys;
    }
1282365
public static function searchMediaTypes(string $pattern):array
    {
        $pattern = strtolower($pattern);
        $results = [];
        foreach (self::getMediaTypes() as $extension => $mediaType) {
            if (fnmatch($pattern, $mediaType)) {
                $results[$extension] = $mediaType;
            }
        }
        return $results;
    }
700496
protected function extractDefaultValues(
        /*# string */ $pattern
    )/*# : string */ {
        $regex = '~\{([a-zA-Z][a-zA-Z0-9_]*+)[^\}]*(=[a-zA-Z0-9._]++)\}~';
        if (preg_match_all($regex, $pattern, $matches, \PREG_SET_ORDER)) {
            $srch = $repl = $vals = [];
            foreach ($matches as $m) {
                $srch[] = $m[0];
                $repl[] = str_replace($m[2], '', $m[0]);
                $vals[$m[1]] = substr($m[2],1);
            }
            $this->setDefault($vals);
            return str_replace($srch, $repl, $pattern);
        }
        return $pattern;
    }
186578
public static String format(final Date date, final String pattern) {
        return format(date, pattern, null, null);
    }
849448
private function getIniPart(string $pattern) : array
    {
        $pattern = strtolower($pattern);
        $patternhash = Pattern::getHashForParts($pattern);
        $subkey = SubKey::getIniPartCacheSubKey($patternhash);

        try {
            if (! $this->cache->hasItem('browscap.iniparts.' . $subkey, true)) {
                $this->logger->debug('cache key "browscap.iniparts.' . $subkey . '" not found');

                return [];
            }
        } catch (InvalidArgumentException $e) {
            $this->logger->error(new \InvalidArgumentException('an error occured while checking a inipart in the cache', 0, $e));

            return [];
        }

        $success = null;

        try {
            $file = $this->cache->getItem('browscap.iniparts.' . $subkey, true, $success);
        } catch (InvalidArgumentException $e) {
            $this->logger->error(new \InvalidArgumentException('an error occured while reading a inipart from the cache', 0, $e));

            return [];
        }

        if (! $success) {
            $this->logger->debug('cache key "browscap.iniparts.' . $subkey . '" not found');

            return [];
        }

        if (! is_array($file) || ! count($file)) {
            $this->logger->debug('cache key "browscap.iniparts.' . $subkey . '" was empty');

            return [];
        }

        $propertyFormatter = new PropertyFormatter(new PropertyHolder());
        $return = [];

        foreach ($file as $buffer) {
            [$tmpBuffer, $patterns] = explode("\t", $buffer, 2);

            if ($tmpBuffer === $patternhash) {
                try {
                    $return = \ExceptionalJSON\decode($patterns, true);
                } catch (DecodeErrorException $e) {
                    $this->logger->error('data for cache key "browscap.iniparts.' . $subkey . '" are not valid json');

                    return [];
                }

                foreach (array_keys($return) as $property) {
                    $return[$property] = $propertyFormatter->formatPropertyValue(
                        $return[$property],
                        (string) $property
                    );
                }

                break;
            }
        }

        return $return;
    }
55234
protected function formatWeekInYear($pattern,$date)
	{
		if($pattern==='w')
			return @date('W',@mktime(0,0,0,$date['mon'],$date['mday'],$date['year']));
		else
			throw new CException(Yii::t('yii','The pattern for week in year must be "w".'));
	}
802991
protected function getSegments($pattern)
	{
		$segments = array();
		$parts = \explode("/", ltrim($pattern, "/"));

		foreach ($parts as $segment)
		{
			if (\strpos($segment, ":") !== false)
			{
				$segments[] = $this->parseSegment($segment);
			}
		}

		return $segments;
	}
1346290
public function glob($pattern)
    {
        $matched = [];
        $pattern = $this->realpath($pattern);
        $pattern = '@^' . str_replace(['\*', '\?'], ['[^\\\/]*', '.'], preg_quote($pattern)) .'$@';
        foreach (array_keys($this->files) as $path) {
            if (preg_match($pattern, $path))
                $matched[] = $path;
        }
        return $matched;
    }
1177076
public function readWithPattern($text, $pattern) {
		$pieces = explode("\n", $text);
		$result = [];
		foreach ($pieces as $piece) {
			$result[] = sscanf(trim($piece, "\r\n"), $pattern);
		}
		return $result;
	}
345226
private function findinvirtual($pattern)
    {
        $result = array();
        $virtual = null;

        if ($this->file)
            $virtual = file($this->file);

        if (empty($virtual))
            return $result;

        // check each line for matches
        foreach ($virtual as $line) {
            $line = trim($line);
            if (empty($line) || $line[0]=='#')
                continue;

            if (preg_match($pattern, $line))
                $result[] = $line;
        }

        return $result;
    }
1287848
public function getTemplatesByPattern($pattern)
    {
        $templates = array();
        foreach ($this->manageableExt->keys() as $ext) {
            $templates = array_merge($templates, parent::getTemplatesByPattern($pattern.$ext));
        }

        return $templates;
    }
931857
public function rm($pattern = null) {
        if ($pattern) {
            // 指定标签清除
            //$keys = $this->getTagItem($tag);
            $flag = is_array($pattern) && $this->handler->deleteMulti($pattern);
            //$this->rm('tag_' . md5($tag));
            return $flag;
        }
        return $this->handler->flush();
    }
669861
public function filter($pattern)
    {
        return new self(array_filter($this->items, function (AcceptHeaderItem $item) use ($pattern) {
            return preg_match($pattern, $item->getValue());
        }));
    }