当前位置: 首页>>代码示例>>PHP>>正文


PHP mb_ereg函数代码示例

本文整理汇总了PHP中mb_ereg函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_ereg函数的具体用法?PHP mb_ereg怎么用?PHP mb_ereg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mb_ereg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_ereg

function test_ereg($test_enc, $pat, $str, $in_enc = 'EUC-JP')
{
    mb_regex_encoding($test_enc);
    $pat = mb_convert_encoding($pat, $test_enc, $in_enc);
    $str = mb_convert_encoding($str, $test_enc, $in_enc);
    printf("(%d)%s\n", mb_ereg($pat, $str, $reg), is_array($reg) ? bin2hex(mb_convert_encoding(implode(' ', $reg), $in_enc, $test_enc)) : '');
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:mb_ereg.php

示例2: trim

 static function trim($value, $max_length, $is_html = false)
 {
     if (UTF8::len($value) > $max_length) {
         $value = UTF8::sub($value, 0, $max_length);
         // TODO: replace this with cleanstring of ctools
         $regex = '(.*)\\b.+';
         $matches = array();
         if (function_exists('mb_ereg')) {
             mb_regex_encoding('UTF-8');
             $found = mb_ereg($regex, $value, $matches);
         } else {
             $found = preg_match("/{$regex}/us", $value, $matches);
         }
         if ($found) {
             $value = $matches[1];
         }
         if ($is_html) {
             // Remove scraps of HTML entities from the end of a strings
             $regex = '/(?:<(?!.+>)|&(?!.+;)).*$/s';
             $value2 = preg_replace($regex . 'u', '', $value);
             if (preg_last_error() == 4) {
                 $value = preg_replace($regex, '', $value);
             } else {
                 $value = $value2;
             }
         }
         $value = rtrim($value);
         $value .= '...';
     }
     if ($is_html) {
         $value = self::_filter_htmlcorrector($value);
     }
     return $value;
 }
开发者ID:splitice,项目名称:radical-basic,代码行数:34,代码来源:Truncate.php

示例3: do_url

 function do_url()
 {
     if (!keys_exists(Vars::$post, 'num', 'type', 'pagename')) {
         throw new PluginException('パラメータが足りません。', $this);
     }
     if (trim(Vars::$post['text']) == '') {
         redirect(Page::getinstance(Vars::$post['pagename']));
     }
     $page = Page::getinstance(Vars::$post['pagename']);
     $source = explode("\n", Page::getinstance(Vars::$post['pagename'])->getsource());
     $count = 0;
     for ($i = 0; $i < count($source); $i++) {
         if (mb_ereg('^#comment(?:\\s|\\(|{|$)', $source[$i])) {
             if ($count == Vars::$post['num']) {
                 $name = trim(Vars::$post['name']);
                 $text = mb_ereg_replace('{', '&173;', Vars::$post['text']);
                 $text = mb_ereg_replace('}', '&175;', $text);
                 $time = date('Y-m-d H:i:s', time());
                 $str = ":[[{$name}>UserPage/{$name}]] &size(80%) {{$time}}:";
                 $str .= mb_ereg("\n", $str) ? "\n#block{{$text}}" : " {$text}";
                 $n = $i + (Vars::$post['type'] == 'below' ? 1 : 0);
                 array_splice($source, $n, 0, $str);
                 $page->write(join("\n", $source));
                 setcookie('name', $name, time() + 60 * 60 * 24 * 30);
                 redirect($page);
             }
             $count++;
         }
     }
     $ret['title'] = 'error';
     $smarty = $this->getSmarty();
     $smarty->assign('text', Vars::$post['text']);
     $ret['body'] = $smarty->fetch('error.tpl.htm');
     return $ret;
 }
开发者ID:kaz6120,项目名称:BitWiki,代码行数:35,代码来源:comment.inc.php

示例4: getPreview

 public static function getPreview($originalImage, $previewWidth, $previewHeight, $shared = true, $fill = '#ffffff', $cut = false)
 {
     $original = $originalImage;
     //relative path
     if (!mb_ereg('^' . DOCROOT, $original)) {
         //remove heading slashes
         if (mb_substr($original, 0, 1) == '/' || mb_substr($original, 0, 1) == '\\') {
             $original = mb_substr($original, 1);
         }
         $original = DOCROOT . $original;
     }
     Admin::createDirectoryIfNotExists(self::getPreviewsDir());
     if (file_exists($original)) {
         $previewName = self::getPreviewName($original, $previewWidth, $previewHeight, $fill, $cut);
         if (!file_exists($previewName)) {
             self::createPreview($original, $previewWidth, $previewHeight, $fill, $cut);
         }
         if ($shared === true) {
             return mb_substr($previewName, mb_strlen(DOCROOT) - 1);
         }
         return $previewName;
     } else {
         throw new Exception('Image file ' . $original . ' not found!');
     }
 }
开发者ID:s4urp8n,项目名称:kohana-admin,代码行数:25,代码来源:ImagePreview.php

示例5: do_block

 function do_block($page, $param1, $param2)
 {
     $prefix = trim($param1);
     $pattern = '^' . mb_ereg_quote($prefix) . '/(\\d{1,4})-(\\d{2})';
     if (mb_ereg($pattern, $page->getpagename(), $m)) {
         $year = $m[1];
         $month = $m[2];
     } else {
         if (isset(Vars::$get['year']) && isset(Vars::$get['month'])) {
             $year = Vars::$get['year'];
             $month = Vars::$get['month'];
         } else {
             $year = date('Y');
             $month = date('n');
         }
     }
     $smarty = $this->getSmarty();
     $day = 1;
     $last = date('t', mktime(0, 0, 0, $month, 1, $year));
     while ($day <= $last) {
         $line = array_fill(0, 7, '&nbsp;');
         $d = date('w', mktime(0, 0, 0, $month, $day, $year));
         for (; $d < 7 && $day <= $last; $d++, $day++) {
             $p = Page::getinstance(sprintf('%s/%04d-%02d-%02d', $prefix, $year, $month, $day));
             $line[$d] = $p->isexist() ? makelink($p, $day) : $day;
         }
         $table[] = $line;
     }
     $smarty->assign('table', $table);
     $smarty->assign('year', $year);
     $smarty->assign('month', $month);
     $smarty->assign('prefix', $prefix);
     $smarty->assign('page', $page->getpagename());
     return $smarty->fetch('blogcalendar.tpl.htm');
 }
开发者ID:kaz6120,项目名称:BitWiki,代码行数:35,代码来源:blogcalendar.inc.php

示例6: do_url

 function do_url()
 {
     if (!keys_exists(Vars::$post, 'num', 'pagename')) {
         throw new PluginException('パラメータが足りません。', $this);
     }
     if (trim(Vars::$post['text']) == '') {
         redirect(Page::getinstance(Vars::$post['pagename']));
     }
     $page = Page::getinstance(Vars::$post['pagename']);
     $source = explode("\n", Page::getinstance(Vars::$post['pagename'])->getsource());
     $count = 0;
     for ($i = 0; $i < count($source); $i++) {
         if (mb_ereg('^#bbsres(?:\\s|\\(|{|$)', $source[$i])) {
             if ($count == Vars::$post['num']) {
                 $name = isset(Vars::$post['name']) ? trim(Vars::$post['name']) : '';
                 $smarty = $this->getSmarty();
                 $smarty->assign('name', $name);
                 $smarty->assign('text', Vars::$post['text']);
                 $smarty->assign('timestamp', time());
                 array_splice($source, $i, 0, $smarty->fetch('bbsres.tpl'));
                 $page->write(join("\n", $source));
                 setcookie('name', trim($name), time() + 60 * 60 * 24 * 30);
                 redirect($page);
             }
             $count++;
         }
     }
     $ret['title'] = 'error';
     $smarty = $this->getSmarty();
     $smarty->assign('text', Vars::$post['text']);
     $ret['body'] = $smarty->fetch('error.tpl.htm');
     return $ret;
 }
开发者ID:riaf,项目名称:kinowiki,代码行数:33,代码来源:bbsres.inc.php

示例7: validateNoControlCharacters

 /**
  * @param $attribute
  * @param $value
  * @param $parameters
  * @return bool
  */
 public function validateNoControlCharacters($attribute, $value, $parameters)
 {
     if (mb_ereg('\\A[[:^cntrl:]]*\\z', $value)) {
         return true;
     }
     return false;
 }
开发者ID:sibukixxx,项目名称:Laravel5.SampleApplication,代码行数:13,代码来源:ParameterValidator.php

示例8: modifyWord

 private function modifyWord($word)
 {
     if (mb_ereg('[_a-zA-Z0-9]+$', $word)) {
         $word .= " ";
     }
     return $word;
 }
开发者ID:hidetobara,项目名称:VolatileTwit,代码行数:7,代码来源:BlockState.class.php

示例9: __construct

 public function __construct(array $map)
 {
     foreach ($map as $location => $app) {
         if (!is_callable($app)) {
             throw new InvalidApplicationException('invalid app supplied for "' . $location . '" path');
         }
         $i = new \stdClass();
         $i->app = $app;
         $parts = array();
         if (false !== mb_ereg('\\Ahttps?://(.*?)(/.*)', $location, $parts)) {
             $i->host = $parts[1];
             $i->location = $parts[2];
         } else {
             $i->host = null;
             $i->location = $location;
         }
         if ($i->location[0] != '/') {
             throw new URLMap\UnexpectedValueException('Location has to start with "/"');
         }
         $this->mapping[] = $i;
     }
     usort($this->mapping, function ($a, $b) {
         if (0 != ($h = strlen($b->host) - strlen($a->host))) {
             return $h;
         }
         return strlen($b->location) - strlen($a->location);
     });
 }
开发者ID:LookForwardPersistence,项目名称:appserver-in-php,代码行数:28,代码来源:URLMap.php

示例10: do_block

 function do_block($page, $param1, $param2)
 {
     if (!mb_ereg('^\\s*(.+?)\\s*,\\s*(\\d+)\\s*$', $param1, $m) || $m[2] <= 0) {
         throw new PluginException('引数が正しくありません。', $this);
     }
     $home = $m[1];
     $num = $m[2];
     $p = isset(Vars::$get['p']) ? max(0, Vars::$get['p']) : 0;
     $datelist = Plugin_blognavi_DateList::getinstance($home);
     $collist = Plugin_blognavi_ColumnList::getinstance($datelist);
     $pagename = $collist->getlast();
     for ($i = 0; $i < $num * $p; $i++) {
         $pagename = $collist->getprev($pagename);
     }
     $ret = array();
     for ($i = 0; $i < $num; $i++) {
         if ($pagename == null) {
             break;
         }
         $ret[] = $this->includepage($pagename);
         $pagename = $collist->getprev($pagename);
     }
     $smarty = $this->getSmarty();
     $smarty->assign('pagename', $page->getpagename());
     if ($p > 0) {
         $smarty->assign('next', $p - 1);
     }
     $smarty->assign('prev', $p + 1);
     $smarty->assign('body', join("\n", $ret));
     return $smarty->fetch('blogviewer.tpl.htm');
 }
开发者ID:riaf,项目名称:kinowiki,代码行数:31,代码来源:blogviewer.inc.php

示例11: get_style_selection_info_array

 /**
  * acsスタイル選択情報の取得
  *
  * @param string $lang 言語種別
  * @param string $encoding 文字エンコーディング
  */
 function get_style_selection_info_array($lang, $encoding = '')
 {
     if ($encoding != '') {
         mb_regex_encoding($encoding);
     }
     $pattern = 'acs_style_selection[ \\t]*\\{([^\\}]+)\\}';
     $result = mb_ereg($pattern, $this->css_file_contents, $regs);
     if ($result != FALSE) {
         $styles = trim($regs[1]);
         $pattern_fmt = '.*%s[ \\t\\n\\r\\f\\v]*:*([^;]+);';
         $result = array();
         // 各パラメータの取得
         mb_ereg(sprintf($pattern_fmt, 'show_list'), $styles, $regs);
         $result['show_list'] = trim($regs[1]);
         mb_ereg(sprintf($pattern_fmt, 'display_order'), $styles, $regs);
         $result['display_order'] = trim($regs[1]);
         // 言語依存パラメータの取得
         mb_ereg(sprintf($pattern_fmt, 'name\\.' . $lang), $styles, $regs);
         $result['name'] = trim($regs[1]);
         mb_ereg(sprintf($pattern_fmt, 'description\\.' . $lang), $styles, $regs);
         $result['description'] = trim($regs[1]);
         mb_ereg(sprintf($pattern_fmt, 'thumbnail\\.' . $lang), $styles, $regs);
         $result['thumbnail'] = trim($regs[1]);
         $result['filename'] = basename($this->css_file_path);
     }
     return $result;
 }
开发者ID:nkawa,项目名称:acs-git-test,代码行数:33,代码来源:ACSCss.class.php

示例12: chk_kana

function chk_kana($str, $option = "")
{
    if (mb_ereg("[^ア-ン" . $option . "]+\$", $str)) {
        $err = 1;
    }
    return $err;
}
开发者ID:aim-web-projects,项目名称:ueno-chuoh,代码行数:7,代码来源:form_chk.php

示例13: validation_default

 private static function validation_default($val, $min_len = 0, $max_len = 60, $regex_opt = '')
 {
     if (!is_string($val)) {
         // validation_exit('Invalid type', gettype($val));
         return "";
     }
     if (strlen($val) < $min_len || strlen($val) > $max_len) {
         validation_exit('Too long value', strlen($val));
         return "";
     }
     // Only UTF-8 is supported.
     // WARNING: This code assumes UTF-8 only script.
     if (ini_get('default_charset') != 'UTF-8') {
         // validation_exit('Only UTF-8 is supported', $val);
         return "";
     }
     if (!mb_check_encoding($val, 'UTF-8')) {
         // validation_exit('Invalid encoding', $val);
         return "";
     }
     // Allow only alpha numeric and UTF-8.
     // UTF-8 encoding:
     //   0xxxxxxx
     //   110yyyyx + 10xxxxxx
     //   1110yyyy + 10yxxxxx + 10xxxxxx
     //   11110yyy + 10yyxxxx + 10xxxxxx + 10xxxxxx
     // Since validity of UTF-8 encoding is checked, simply allow \x80-\xFF.
     if (!mb_ereg('\\A[0-9A-Za-z\\x80-\\xFF' . $regex_opt . ']*\\z', $val)) {
         // validation_exit('Invalid char', $val);
     }
     return $val;
 }
开发者ID:K-atc,项目名称:Kch,代码行数:32,代码来源:WAF.php

示例14: peg_regex_test

 function peg_regex_test($pattern, $string)
 {
     if (substr($pattern, -1) == 'i') {
         return mb_eregi(substr($pattern, 1, -2), $string);
     } else {
         return mb_ereg(substr($pattern, 1, -1), $string);
     }
 }
开发者ID:fr-esco,项目名称:php-dice,代码行数:8,代码来源:BaseParser.php

示例15: check_string_if_character_arabic

function check_string_if_character_arabic($string)
{
    if (mb_ereg('[\\x{0600}-\\x{06FF}]', $string)) {
        return true;
    } else {
        return false;
    }
}
开发者ID:VoilaVoila,项目名称:voilacms,代码行数:8,代码来源:upload.php


注:本文中的mb_ereg函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。