本文整理汇总了PHP中Common::regex方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::regex方法的具体用法?PHP Common::regex怎么用?PHP Common::regex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common
的用法示例。
在下文中一共展示了Common::regex方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseValue
private static function parseValue($arg, $key)
{
if (false === ($back = Common::regex('/(\\d{1,}[\\.,]?\\d{0,3}) *' . $key . '/i', $arg))) {
return -1;
}
return floatval(str_replace(',', '.', $back));
}
示例2: testSmiley
public static function testSmiley(WC_Challenge $chall, $smiley, $path)
{
$back = true;
# Test passed :S?
# Generate test input :)
$ues = str_replace('\\', '', $smiley);
$ues = Common::regex('#/([^/]+)/#', $ues);
$text = 'Test ' . $ues . '. Test ' . $ues;
echo GWF_Box::box($text, $chall->lang('test_input'));
# Generate test output :)
if (NULL === ($out = self::replaceSmiley($smiley, $path, $text))) {
$back = false;
$out = $text;
}
# Output the test :)
echo GWF_Box::box($out, $chall->lang('test_output'));
return $back;
}
示例3: getElevatorN
private function getElevatorN()
{
$c = $this->getElevatorCity();
$floor = Common::regex("/^{$c}([C0-9]*)_/", $this->getName());
if ($floor === '') {
return 0;
} elseif ($floor[0] === 'C') {
return -intval(substr($floor, 1), 10);
} else {
return intval($floor, 10) - 1;
}
}
示例4: getDomain
/**
*
* @param string $url
* @return Ambigous <string, false, boolean, unknown>
*/
public static function getDomain($url)
{
$url = Common::substrFrom($url, '://', $url);
$url = Common::substrUntil($url, '/', $url);
return Common::regex('#([^\\.]+\\.[^\\.]+)$#D', $url);
}
示例5: getByLongName
public static function getByLongName($username)
{
if (0 === ($sid = (int) Common::regex('/^.+\\{(\\d+)\\}$/', $username))) {
return false;
}
$username = Shadowfunc::toShortname($username);
$username = self::escape($username);
if (false === ($player = self::table(__CLASS__)->selectFirstObject('*', "sr4pl_sid={$sid} AND sr4pl_name='{$username}'"))) {
return false;
}
return self::reloadPlayer($player);
}
示例6: getDescription
private function getDescription($url)
{
# Get page content
# TODO: Only download .txt and .html content!
GWF_HTTP::setTimeout(10);
GWF_HTTP::setConnectTimeout(3);
$content = GWF_HTTP::getFromURL($url, true);
GWF_HTTP::setTimeout();
GWF_HTTP::setConnectTimeout();
if ($content === false) {
Dog_Log::error('Mod_Link::getDescription(): getFromURL() failed. URL: ' . $url);
return false;
}
list($head, $content) = preg_split("/[\r\n]{4}/", $content, 2);
$type = Common::regex('/Content-Type: *(.*)/Di', $head);
echo $type . PHP_EOL;
if (Common::startsWith($type, 'image')) {
return array('image', $content);
}
# Get Title from html
if (0 === preg_match('#< *title *>([^<]+)< */ *title *>#i', $content, $matches)) {
return false;
}
$title = $this->decode($matches[1]);
$descr = '';
if (1 === preg_match('#(< *meta.*description[^>]*>)#i', $content, $matchesB)) {
$tag = $matchesB[1];
if (1 === preg_match('#content=["\']([^"\']+)["\']#', $tag, $matchesB)) {
$descr = ' - ' . $this->decode($matchesB[1]);
}
}
return array('html', $title . ' - ' . $descr);
}
示例7: getLevelNum
public function getLevelNum()
{
$back = Common::regex('/(\\d+)/', $this->getTitle());
return $back < 1 ? false : (int) $back;
}
示例8: warscore_get_level_num
function warscore_get_level_num($level)
{
return Common::regex('/(\\d+)/', $level);
}
示例9: matchSymbols
public static function matchSymbols($username)
{
$pattern = preg_quote(self::allSymbols());
$pattern = "/^([{$pattern}]+)/";
return Common::regex($pattern, $username);
}