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


PHP mb_ereg_search函数代码示例

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


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

示例1: setBusyHours

 public function setBusyHours($value)
 {
     $schedule = mb_strtolower($value);
     try {
         if (mb_strpos($schedule, '(')) {
             $schedule = trim(mb_ereg_replace('\\(.*\\)', '', $schedule));
         }
         mb_ereg_search_init($schedule);
         if (mb_ereg_search('[а-я]\\:')) {
             $schedule = mb_ereg_replace('^[\\w-]+\\:', '', $schedule);
             $schedule = mb_ereg_replace(', [\\w-]+\\:', ',', $schedule);
         }
         $schedule = trim($schedule);
         $dayIntervals = explode(',', $schedule);
         foreach ($dayIntervals as $dayInterval) {
             $dayInterval = trim($dayInterval);
             if (mb_strpos($dayInterval, 'обед') === false) {
                 $this->parseDayInterval($dayInterval);
             } else {
                 list($trash, $time) = explode(' ', $dayInterval);
                 $this->parseLunch($time);
             }
         }
         foreach ($this->schedule as $day => &$workingTime) {
             if (isset($workingTime['from'])) {
                 $workingTime = [$workingTime];
             }
         }
     } catch (\Exception $e) {
         $this->schedule = 'error parsing';
     }
 }
开发者ID:consultnn,项目名称:api-client,代码行数:32,代码来源:Schedule.php

示例2: slugName

 /**
  * 生成缩略名
  *
  * @access public
  * @param string $str 需要生成缩略名的字符串
  * @param string $default 默认的缩略名
  * @param integer $maxLength 缩略名最大长度
  * @return string
  */
 public static function slugName($str, $default = NULL, $maxLength = 128)
 {
     $str = trim($str);
     if (!strlen($str)) {
         return $default;
     }
     if (__TYPECHO_MB_SUPPORTED__) {
         mb_regex_encoding(self::$charset);
         mb_ereg_search_init($str, "[\\w" . preg_quote('_-') . "]+");
         $result = mb_ereg_search();
         $return = '';
         if ($result) {
             $regs = mb_ereg_search_getregs();
             $pos = 0;
             do {
                 $return .= ($pos > 0 ? '-' : '') . $regs[0];
                 $pos++;
             } while ($regs = mb_ereg_search_regs());
         }
         $str = $return;
     } else {
         if ('UTF-8' == strtoupper(self::$charset)) {
             if (preg_match_all("/[\\w" . preg_quote('_-') . "]+/u", $str, $matches)) {
                 $str = implode('-', $matches[0]);
             }
         } else {
             $str = str_replace(array("'", ":", "\\", "/", '"'), "", $str);
             $str = str_replace(array("+", ",", ' ', ',', ' ', ".", "?", "=", "&", "!", "<", ">", "(", ")", "[", "]", "{", "}"), "-", $str);
         }
     }
     $str = trim($str, '-_');
     $str = !strlen($str) ? $default : $str;
     return substr($str, 0, $maxLength);
 }
开发者ID:jiusanzhou,项目名称:spacms,代码行数:43,代码来源:Common.php

示例3: setFn

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Match', function ($Call) {
    $Pockets = null;
    mb_ereg($Call['Pattern'], $Call['Value'], $Pockets, $Call['Regex Options']);
    return $Pockets;
});
setFn('All', function ($Call) {
    $Results = [];
    mb_ereg_search_init($Call['Value'], $Call['Pattern'], $Call['Regex Options']);
    $Result = mb_ereg_search();
    if ($Result) {
        $Result = mb_ereg_search_getregs();
        //get first result
        do {
            foreach ($Result as $IX => $Value) {
                $Results[$IX][] = $Value;
            }
            $Result = mb_ereg_search_regs();
            //get next result
        } while ($Result);
    } else {
        $Results = false;
    }
    return $Results;
});
开发者ID:trickyplan,项目名称:codeine,代码行数:30,代码来源:Oniguruma.php

示例4: findLangs

 public function findLangs($dir = '')
 {
     if (!in_array($dir, self::$PARSED_PATHS)) {
         $baseDir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
         foreach ($baseDir as $file) {
             if ($file->isFile()) {
                 if (in_array($file->getExtension(), self::$ALLOW_EXTENSIONS) && !strstr($file->getBasename(), 'jsLangs')) {
                     $content = @file($file->getPathname());
                     $implode_content = implode(' ', $content);
                     $lang_exist = FALSE;
                     foreach (self::$PARSE_REGEXPR as $regexpr) {
                         $lang_exist = $lang_exist || preg_match('/' . $regexpr . '/', $implode_content);
                     }
                     if ($lang_exist) {
                         foreach ($content as $line_number => $line) {
                             foreach (self::$PARSE_REGEXPR as $regexpr) {
                                 $lang = array();
                                 mb_regex_encoding("UTF-8");
                                 mb_ereg_search_init($line, $regexpr);
                                 $lang = mb_ereg_search();
                                 if ($lang) {
                                     $lang = mb_ereg_search_getregs();
                                     //get first result
                                     do {
                                         $origin = mb_ereg_replace('!\\s+!', ' ', $lang[1]);
                                         if (!self::$FINDED_LANGS[$origin]) {
                                             self::$FINDED_LANGS[$origin] = array();
                                         }
                                         if ($file->getExtension() == 'js') {
                                             self::$FINDED_JS_LANGS[$origin] = $origin;
                                         }
                                         $path = str_replace("\\", "/", $file->getPathname());
                                         array_push(self::$FINDED_LANGS[$origin], $path . ':' . ($line_number + 1));
                                         $lang = mb_ereg_search_regs();
                                         //get next result
                                     } while ($lang);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     self::$PARSED_PATHS[] = $dir;
     $data = array('parsed_langs' => self::$FINDED_LANGS, 'js_langs' => self::$FINDED_JS_LANGS);
     self::$FINDED_LANGS = array();
     self::$FINDED_JS_LANGS = array();
     return $data;
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:50,代码来源:FilesParser.php

示例5: addWords

 private function addWords($fullid, $text, $weight)
 {
     if (!$text) {
         return;
     }
     if (self::$ismb) {
         mb_ereg_search_init($text, "\\w+");
         if (mb_ereg_search()) {
             $match = mb_ereg_search_getregs();
             do {
                 $word = mb_strtolower($match[0], 'UTF-8');
                 if (!isset($this->words[$word])) {
                     $this->words[$word] = array($fullid => $weight);
                 } else {
                     if (!isset($this->words[$word][$fullid])) {
                         $this->words[$word][$fullid] = $weight;
                     } else {
                         $this->words[$word][$fullid] += $weight;
                     }
                 }
                 $match = mb_ereg_search_regs();
             } while ($match);
         }
     } else {
         preg_match_all("/\\w+/", $text, $matches);
         foreach ($matches[0] as $word) {
             $word = strtolower($word);
             if (!isset($this->words[$word])) {
                 $this->words[$word] = array($fullid => $weight);
             } else {
                 if (!isset($this->words[$word][$fullid])) {
                     $this->words[$word][$fullid] = $weight;
                 } else {
                     $this->words[$word][$fullid] += $weight;
                 }
             }
         }
     }
 }
开发者ID:sevenns,项目名称:alpremstroy,代码行数:39,代码来源:indexer.class.php

示例6: filter

 /**
  * Regular expression filter and return only replaced.
  *
  * Warning, take care that callback does not trigger any errors or the PHP will just die with some weird exit code.
  *
  * @param string|string[]         $pattern     Pattern or array of patterns
  * @param callable|string|mixed[] $replacement Replacement (string or callback) or array of replacements
  * @param string|string[]         $subject     Subject or array of subjects
  * @param string                  $option      Option
  * @return string[] Array of filtered subjects
  * @throws MbRegexException When compilation error occurs
  * @link http://php.net/function.mb-ereg-search.php
  * @link http://php.net/function.mb-ereg-replace.php
  * @link http://php.net/function.mb-ereg-replace-callback.php
  */
 public static function filter($pattern, $replacement, $subject, $option = '')
 {
     static::setUp($pattern);
     $replaceMap = self::prepareReplaceMap($pattern, $replacement);
     $result = array();
     foreach ((array) $subject as $key => $subjectPart) {
         foreach ($replaceMap as $item) {
             list($pattern, $replacement) = $item;
             \mb_ereg_search_init($subjectPart, $pattern, $option);
             if (!\mb_ereg_search()) {
                 continue;
             }
             $subjectPart = self::execReplace($pattern, $replacement, $subjectPart, $option);
             $result[$key] = $subjectPart;
         }
     }
     static::tearDown();
     return $result;
 }
开发者ID:xtlxs1976,项目名称:regex,代码行数:34,代码来源:MbRegex.php

示例7: detectAA

 /**
  * AA判定
  *
  * @param string $msg
  * @return bool
  */
 public function detectAA($msg)
 {
     if (substr_count($msg, $this->_lb) < $this->_ln) {
         return false;
     } elseif (substr_count($msg, '  ') > 5) {
         return true;
     } elseif (!mb_ereg_search_init($msg, self::REGEX)) {
         return false;
     } else {
         $i = 0;
         while ($i < 3 && mb_ereg_search()) {
             $i++;
         }
         return $i == 3;
     }
 }
开发者ID:xingskycn,项目名称:p2-php,代码行数:22,代码来源:ActiveMona.php

示例8: error_reporting

<?php

error_reporting(0);
var_dump(mb_ereg_search('abc', ''));
开发者ID:badlamer,项目名称:hhvm,代码行数:4,代码来源:mb_ereg_search_crash.php

示例9: match

 function match($regexp, $text, &$match)
 {
     if (!is_callable('mb_ereg_search_init')) {
         if (!preg_match($regexp, $text, $match)) {
             return false;
         }
         $match = $match[0];
         return true;
     }
     $regexp = substr($regexp, 1, strlen($regexp) - 2 - strlen($this->_re_flags));
     mb_ereg_search_init($text);
     if (!mb_ereg_search($regexp)) {
         return false;
     }
     $match = mb_ereg_search_getregs();
     return true;
 }
开发者ID:Blu2z,项目名称:implsk,代码行数:17,代码来源:Parse.php

示例10: comesExpression

 protected function comesExpression($pattern, $options = 'msi')
 {
     /*{{{*/
     if ($this->position > $this->length) {
         return false;
     }
     //return preg_match('/\G'.$pattern.'/iu', $this->text, $matches, 0, $this->bytepos);
     mb_ereg_search_init($this->text, '\\G' . $pattern, $options);
     mb_ereg_search_setpos($this->bytepos);
     return mb_ereg_search();
 }
开发者ID:ju1ius,项目名称:libphp,代码行数:11,代码来源:Lexer.php

示例11: mark

 public static function mark($html, $words = array())
 {
     if (!$words || count($words) <= 0) {
         return $html;
     }
     $ismb = function_exists('mb_ereg_search');
     $inlineTags = 'b|i|em|strong|tt|big|small|strike|u|span|a';
     $ignoreTags = 'script|style|textarea';
     $pattern = '';
     foreach ($words as $word) {
         if ($pattern != '') {
             $pattern .= '|';
         }
         $pattern .= $ismb ? mb_strtolower($word, 'UTF-8') : strtolower($word);
         if ($ismb && mb_strlen($word, 'UTF-8') >= 3 || !$ismb && strlen($word) >= 3) {
             $pattern .= '\\w*';
         }
     }
     $newhtml = '';
     $currPart = '';
     $currWord = '';
     $ignore = false;
     if ($ismb) {
         mb_regex_encoding('UTF-8');
         mb_ereg_search_init($html, '(\\w+)|([^<\\w]+)|<(\\/?[a-zA-Z-])[^>]*>|(<!--.*?-->|\\(%.*?%\\)|\\{%.*?%\\})');
         if (mb_ereg_search()) {
             $match = mb_ereg_search_getregs();
             do {
                 if ($ignore || $match[2] || $match[4] || $match[3] && !mb_ereg_match("\\/?({$inlineTags})", mb_strtolower($match[3], 'UTF-8'))) {
                     if ($currWord && mb_ereg_match($pattern, $currWord)) {
                         $newhtml .= self::markIt($currPart);
                     } else {
                         $newhtml .= $currPart;
                     }
                     $currPart = $currWord = '';
                     if ($ignore) {
                         if ($ignore && $match[3] && $match[3] == $ignore) {
                             $ignore = false;
                         }
                     } else {
                         if ($match[3] && mb_ereg_match("{$ignoreTags}", mb_strtolower($match[3], 'UTF-8')) && substr($match[0], -2) != '/>') {
                             $ignore = '/' . $match[3];
                         }
                     }
                     $newhtml .= $match[0];
                 } else {
                     if ($match[1]) {
                         $currWord .= mb_strtolower($match[1], 'UTF-8');
                     }
                     $currPart .= $match[0];
                 }
                 $match = mb_ereg_search_regs();
             } while ($match);
             if ($currWord && mb_ereg_match($pattern, $currWord)) {
                 $newhtml .= self::markIt($currPart);
             } else {
                 $newhtml .= $currPart;
             }
         }
     } else {
         if (preg_match_all('/(\\w+)|([^<\\w]+)|<(\\/?[a-zA-Z-])[^>]*>|(<!--.*?-->|\\(%.*?%\\)|\\{%.*?%\\})/i', $html, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $match) {
                 if ($ignore || $match[2] || $match[4] || $match[3] && !preg_match("/^\\/?({$inlineTags})\$/i", $match[3])) {
                     if ($currWord && preg_match("/^{$pattern}\$/", $currWord)) {
                         $newhtml .= self::markIt($currPart);
                     } else {
                         $newhtml .= $currPart;
                     }
                     $currPart = $currWord = '';
                     if ($ignore) {
                         if ($ignore && $match[3] && $match[3] == $ignore) {
                             $ignore = false;
                         }
                     } else {
                         if ($match[3] && preg_match("/^{$ignoreTags}\$/i", $match[3]) && substr($match[0], -2) != '/>') {
                             $ignore = '/' . $match[3];
                         }
                     }
                     $newhtml .= $match[0];
                 } else {
                     if ($match[1]) {
                         $currWord .= strtolower($match[1]);
                     }
                     $currPart .= $match[0];
                 }
             }
             if ($currWord && preg_match("/^{$pattern}\$/", $currWord)) {
                 $newhtml .= self::markIt($currPart);
             } else {
                 $newhtml .= $currPart;
             }
         }
     }
     return $newhtml;
 }
开发者ID:sevenns,项目名称:alpremstroy,代码行数:95,代码来源:marker.class.php

示例12: has_special_chars

 /**
  * Check for special characters such as delimiter, quote_char
  * 
  * @access private
  * @param string $column
  * @return boolean
  */
 private function has_special_chars(&$column)
 {
     $pattern = "[.*" . $this->dialect->delimiter . "|.*" . $this->dialect->quote_char . "]";
     mb_ereg_search_init($column, $pattern);
     $ret = mb_ereg_search();
     return $ret;
 }
开发者ID:jun-a,项目名称:progadv,代码行数:14,代码来源:Writer.php

示例13: guessEncodingHtml

/**
 * Tries to guess the encoding used for an Html document
 *
 * @param string $html a character encoding name
 * @param string $return_loc_info if meta http-equiv info was used to
 *     find the encoding, then if $return_loc_info is true, we
 *     return the location of charset substring. This allows converting to
 *     UTF-8 later so cached pages will display correctly and
 *     redirects without char encoding won't be given a different hash.
 *
 * @return mixed either string or array if string then guessed encoding,
 *     if array guessed encoding, start_pos of where charset info came from,
 *     length
 */
function guessEncodingHtml($html, $return_loc_info = false)
{
    /*
      If the doc is HTML and it uses a http-equiv to set the encoding
      then we override what the server says (if anything). As we
      are going to convert to UTF-8 we remove the charset info
      from the meta tag so cached pages will display correctly and
      redirects without char encoding won't be given a different hash.
    */
    $end_head = stripos($html, "</head");
    if ($end_head) {
        $reg = "/charset(\\s*)=(\\s*)(\\'|\")?((\\w|\\-)+)(\\'|\")?/u";
        $is_match = preg_match($reg, $html, $match);
        if (!$is_match) {
            $reg = "charset(\\s*)=(\\s*)(\\'|\")?((\\w|\\-)+)(\\'|\")?";
            mb_regex_encoding("UTF-8");
            mb_ereg_search_init($html);
            mb_ereg_search($reg);
            $match = mb_ereg_search_getregs();
            if (isset($match[0])) {
                $is_match = true;
            }
        }
        if ($is_match && isset($match[6])) {
            $len_c = strlen($match[0]);
            if (($match[6] == "'" || $match[6] == '"') && $match[3] != $match[6]) {
                $len_c--;
            }
            $start_charset = strpos($html, $match[0]);
            if ($start_charset + $len_c < $end_head) {
                if (isset($match[4])) {
                    $encoding = strtoupper($match[4]);
                    if ($return_loc_info) {
                        return array($encoding, $start_charset, $len_c);
                    }
                    return $encoding;
                }
            }
        }
    }
    return mb_detect_encoding($html, 'auto');
}
开发者ID:yakar,项目名称:yioop,代码行数:56,代码来源:locale_functions.php

示例14: p2_mb_ereg_count

/**
 * マルチバイト正規表現にマッチした回数を返す
 *
 * @param   string $pattern
 * @param   string $string
 * @param   string $option
 * @return  int
 */
function p2_mb_ereg_count($pattern, $string, $option = null)
{
    if ($option === null) {
        if (!mb_ereg_search_init($string, $pattern)) {
            return false;
        }
    } else {
        if (!mb_ereg_search_init($string, $pattern, $option)) {
            return false;
        }
    }
    $i = 0;
    while (mb_ereg_search()) {
        $i++;
    }
    return $i;
}
开发者ID:xingskycn,项目名称:p2-php,代码行数:25,代码来源:global.funcs.php

示例15: match

 function match($regexp, $text, $match)
 {
     if (!is_callable('mb_ereg_search_init')) {
         return preg_match($regexp, $text, $match);
     } else {
         $regexp = substr($regexp, 1, strlen($regexp) - 2 - strlen($this->_re_flags));
         mb_ereg_search_init($text, $regexp);
         if (!mb_ereg_search()) {
             return false;
         }
         list($match) = mb_ereg_search_getregs();
         return true;
     }
 }
开发者ID:raphox,项目名称:php-openid,代码行数:14,代码来源:Parse.php


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