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


PHP mb_ereg_search_init函数代码示例

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


在下文中一共展示了mb_ereg_search_init函数的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: formatString

 /**
  * Format a string data.
  *
  * @param string $str A string.
  *
  * @return string
  */
 protected function formatString($str)
 {
     if (extension_loaded('mbstring')) {
         $originalStr = $str;
         $str = mb_convert_case($str, MB_CASE_TITLE, 'UTF-8');
         // Correct for MB_TITLE_CASE's insistence on uppercasing letters
         // immediately preceded by numerals, eg: 1st -> 1St
         $originalEncoding = mb_regex_encoding();
         mb_regex_encoding('UTF-8');
         // matches an upper case letter character immediately preceded by a numeral
         mb_ereg_search_init($str, '[0-9]\\p{Lu}');
         while ($match = mb_ereg_search_pos()) {
             $charPos = $match[0] + 1;
             // Only swap it back to lowercase if it was lowercase to begin with
             if (mb_ereg_match('\\p{Ll}', $originalStr[$charPos])) {
                 $str[$charPos] = mb_strtolower($str[$charPos]);
             }
         }
         mb_regex_encoding($originalEncoding);
     } else {
         $str = $this->lowerize($str);
         $str = ucwords($str);
     }
     $str = str_replace('-', '- ', $str);
     $str = str_replace('- ', '-', $str);
     return $str;
 }
开发者ID:edwinflores,项目名称:geolocation-goal,代码行数:34,代码来源:AbstractResult.php

示例3: splitExtension

 public static function splitExtension($filename)
 {
     mb_regex_encoding('UTF-8');
     $re = "(.*?)((\\.[[A-Z][a-z][0-9]]+)*)\$";
     if ($filename && mb_ereg_search_init($filename, $re)) {
         $matches = mb_ereg_search_regs($re);
         return array_slice($matches, 1, 2);
     } else {
         return [$filename, ''];
     }
 }
开发者ID:Striimin,项目名称:Sanitize,代码行数:11,代码来源:Sanitize.php

示例4: mb_ereg_match_all

function mb_ereg_match_all($pattern, $subject, array &$subpatterns)
{
    if (!mb_ereg_search_init($subject, $pattern)) {
        return false;
    }
    $subpatterns = array();
    while ($r = mb_ereg_search_regs()) {
        $subpatterns[] = $r;
    }
    return true;
}
开发者ID:cmsyog,项目名称:pump,代码行数:11,代码来源:fun.php

示例5: test_search

function test_search($test_enc, $str, $look_for, $opt, $in_enc = 'EUC-JP')
{
    mb_regex_encoding($test_enc);
    $str = mb_convert_encoding($str, $test_enc, $in_enc);
    $look_for = mb_convert_encoding($look_for, $test_enc, $in_enc);
    mb_ereg_search_init($str, $look_for, $opt);
    while (mb_ereg_search_pos()) {
        $regs = mb_ereg_search_getregs();
        array_shift($regs);
        printf("(%s) (%d) %s\n", $test_enc, mb_ereg_search_getpos(), mb_convert_encoding(is_array($regs) ? implode('-', $regs) : '', $in_enc, $test_enc));
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:mb_ereg_search_xxx.php

示例6: translateArgs

 public function translateArgs($lang_string, $args)
 {
     $lang_string = $this->translate($lang_string);
     if (mb_ereg_search_init($lang_string)) {
         while (false != ($vars = mb_ereg_search_regs("{[^{]*}"))) {
             foreach ($vars as $curly_pattern) {
                 $pattern = mb_substr($curly_pattern, 1, mb_strlen($curly_pattern) - 2);
                 $value = $args[$pattern];
                 if (!isset($value)) {
                     $value = $pattern . '-missing';
                 }
                 $lang_string = mb_ereg_replace($curly_pattern, $value, $lang_string);
             }
         }
     }
     return $lang_string;
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:17,代码来源:Translator.php

示例7: mbSplit

 /**
  * A cross between mb_split and preg_split, adding the preg_split flags
  * to mb_split.
  * @param string $pattern
  * @param string $string
  * @param int $limit
  * @param int $flags
  * @return array
  */
 private static function mbSplit($pattern, $string, $limit = -1, $flags = 0)
 {
     $strlen = strlen($string);
     // bytes!
     mb_ereg_search_init($string);
     $lengths = array();
     $position = 0;
     while (($array = mb_ereg_search_pos($pattern, '')) !== false) {
         // capture split
         $lengths[] = array($array[0] - $position, false, null);
         // move position
         $position = $array[0] + $array[1];
         // capture delimiter
         $regs = mb_ereg_search_getregs();
         $lengths[] = array($array[1], true, isset($regs[1]) && $regs[1]);
         // Continue on?
         if ($position >= $strlen) {
             break;
         }
     }
     // Add last bit, if not ending with split
     $lengths[] = array($strlen - $position, false, null);
     // Substrings
     $parts = array();
     $position = 0;
     $count = 1;
     foreach ($lengths as $length) {
         $is_delimiter = $length[1];
         $is_captured = $length[2];
         if ($limit > 0 && !$is_delimiter && ($length[0] || ~$flags & PREG_SPLIT_NO_EMPTY) && ++$count > $limit) {
             if ($length[0] > 0 || ~$flags & PREG_SPLIT_NO_EMPTY) {
                 $parts[] = $flags & PREG_SPLIT_OFFSET_CAPTURE ? array(mb_strcut($string, $position), $position) : mb_strcut($string, $position);
             }
             break;
         } elseif ((!$is_delimiter || $flags & PREG_SPLIT_DELIM_CAPTURE && $is_captured) && ($length[0] || ~$flags & PREG_SPLIT_NO_EMPTY)) {
             $parts[] = $flags & PREG_SPLIT_OFFSET_CAPTURE ? array(mb_strcut($string, $position, $length[0]), $position) : mb_strcut($string, $position, $length[0]);
         }
         $position += $length[0];
     }
     return $parts;
 }
开发者ID:thewildhorse,项目名称:cronlp,代码行数:50,代码来源:SentenceSplitterService.php

示例8: mb_ereg_search_init

<?php

mb_ereg_search_init("", "", "");
mb_split("", "");
mb_ereg_search_regs();
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:empty_pattern.php

示例9: mb_split

 public function &load($data)
 {
     $this->ical = false;
     $regex_opt = 'mib';
     // Lines in the string
     $lines = mb_split('[\\r\\n]+', $data);
     // Delete empty ones
     $last = count($lines);
     for ($i = 0; $i < $last; $i++) {
         if (trim($lines[$i]) == "") {
             unset($lines[$i]);
         }
     }
     $lines = array_values($lines);
     // First and last items
     $first = 0;
     $last = count($lines) - 1;
     if (!(mb_ereg_match('^BEGIN:VCALENDAR', $lines[$first], $regex_opt) and mb_ereg_match('^END:VCALENDAR', $lines[$last], $regex_opt))) {
         $first = null;
         $last = null;
         foreach ($lines as $i => &$line) {
             if (mb_ereg_match('^BEGIN:VCALENDAR', $line, $regex_opt)) {
                 $first = $i;
             }
             if (mb_ereg_match('^END:VCALENDAR', $line, $regex_opt)) {
                 $last = $i;
                 break;
             }
         }
     }
     // Procesing
     if (!is_null($first) and !is_null($last)) {
         $lines = array_slice($lines, $first + 1, $last - $first - 1, true);
         $group = null;
         $parentgroup = null;
         $this->ical = [];
         $addTo = [];
         $addToElement = null;
         reset($lines);
         $line = true;
         while (true) {
             $line = each($lines);
             if ($line === false) {
                 break;
             }
             $line = current($lines);
             if (substr($line, 0, 2) === 'X-' or trim($line) == '') {
                 continue;
             }
             $clave = null;
             $pattern = '^(BEGIN|END)\\:(.+)$';
             // (VALARM|VTODO|VJOURNAL|VEVENT|VFREEBUSY|VCALENDAR|DAYLIGHT|VTIMEZONE|STANDARD)
             mb_ereg_search_init($line);
             $regs = mb_ereg_search_regs($pattern, $regex_opt);
             if ($regs) {
                 // $regs
                 // 0 => BEGIN:VEVENT
                 // 1 => BEGIN
                 // 2 => VEVENT
                 switch ($regs[1]) {
                     case 'BEGIN':
                         if (!is_null($group)) {
                             $parentgroup = $group;
                         }
                         $group = trim($regs[2]);
                         // Adding new values to groups
                         if (is_null($parentgroup)) {
                             if (!array_key_exists($group, $this->ical)) {
                                 $this->ical[$group] = [null];
                             } else {
                                 $this->ical[$group][] = null;
                             }
                         } else {
                             if (!array_key_exists($parentgroup, $this->ical)) {
                                 $this->ical[$parentgroup] = [$group => [null]];
                             }
                             if (!array_key_exists($group, $this->ical[$parentgroup])) {
                                 $this->ical[$parentgroup][$group] = [null];
                             } else {
                                 $this->ical[$parentgroup][$group][] = null;
                             }
                         }
                         break;
                     case 'END':
                         if (is_null($group)) {
                             $parentgroup = null;
                         }
                         $group = null;
                         break;
                 }
                 continue;
             }
             // There are cases like "ATTENDEE" that may take several lines.
             if (!in_array($line[0], [" ", "\t"]) and strpos(':', $line) === false) {
                 $r = current($lines);
                 $concatenar = next($lines);
                 while ($concatenar and in_array($concatenar[0], [" ", "\t"])) {
                     $r .= substr($concatenar, 1);
                     $concatenar = next($lines);
                 }
//.........这里部分代码省略.........
开发者ID:aluguest,项目名称:ical-easy-reader,代码行数:101,代码来源:iCalEasyReader.php

示例10: capitalizeTitleCase

 public static function capitalizeTitleCase($str, $isName = false, $mustCap = true)
 {
     $ret = '';
     if ($str) {
         mb_ereg_search_init($str, StructuredData::$SPLITTER_REGEX);
         $m = mb_ereg_search_regs();
         while ($m) {
             $w = $m[0];
             $ucw = mb_convert_case($w, MB_CASE_UPPER);
             $lcw = mb_convert_case($w, MB_CASE_LOWER);
             if ($isName && mb_strlen($w) > 1 && $w == $ucw) {
                 // turn all-uppercase names into all-lowercase
                 if (mb_strlen($w) > 3 && (mb_substr($w, 0, 2) == 'MC' || mb_substr($w, 0, 2) == "O'")) {
                     $w = mb_substr($w, 0, 1) . mb_substr($lcw, 1, 1) . mb_substr($w, 2, 1) . mb_substr($lcw, 3);
                 } else {
                     $w = $lcw;
                 }
             }
             if (isset(StructuredData::$UPPERCASE_WORDS[$ucw]) || $w == $ucw) {
                 // upper -> upper
                 $ret .= $ucw;
             } else {
                 if (!$mustCap && isset(StructuredData::$NAME_WORDS[$lcw])) {
                     // if w is a name-word, keep as-is
                     $ret .= $w;
                 } else {
                     if (!$isName && !$mustCap && isset(StructuredData::$LOWERCASE_WORDS[$lcw])) {
                         // upper/mixed/lower -> lower
                         $ret .= $lcw;
                     } else {
                         if ($w == $lcw) {
                             // lower -> mixed
                             $ret .= mb_convert_case($w, MB_CASE_TITLE);
                         } else {
                             // mixed -> mixed
                             $ret .= $w;
                         }
                     }
                 }
             }
             $m = mb_ereg_search_regs();
             $w = trim($w);
             $mustCap = !$isName && ($w == ':' || $w == '?' || $w == '!');
         }
     }
     return $ret;
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:47,代码来源:StructuredData.php

示例11: 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

示例12: split_message

	/**
	* Turns text into an array of words
	*/
	function split_message($text)
	{
		global $config;

		// Split words
		if ($this->pcre_properties)
		{
			$text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
		}
		else if ($this->mbstring_regex)
		{
			$text = mb_ereg_replace('([^\w\'*])', '\\1\\1', str_replace('\'\'', '\' \'', trim($text)));
		}
		else
		{
			$text = preg_replace('#([^\w\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
		}

		if ($this->pcre_properties)
		{
			$matches = array();
			preg_match_all('#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u', $text, $matches);
			$text = $matches[1];
		}
		else if ($this->mbstring_regex)
		{
			mb_ereg_search_init($text, '(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)');

			$text = array();
			while (($word = mb_ereg_search_regs()))
			{
				$text[] = $word[1];
			}
		}
		else
		{
			$matches = array();
			preg_match_all('#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#u', $text, $matches);
			$text = $matches[1];
		}

		// remove too short or too long words
		$text = array_values($text);
		for ($i = 0, $n = sizeof($text); $i < $n; $i++)
		{
			$text[$i] = trim($text[$i]);
			if (utf8_strlen($text[$i]) < $config['fulltext_mysql_min_word_len'] || utf8_strlen($text[$i]) > $config['fulltext_mysql_max_word_len'])
			{
				unset($text[$i]);
			}
		}

		return array_values($text);
	}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:57,代码来源:fulltext_mysql.php

示例13: substitueVariables

 public function substitueVariables(&$variables, $lang, $str)
 {
     $langstr = $str;
     // replace variables in string
     if (mb_ereg_search_init($langstr)) {
         while (false != ($vars = mb_ereg_search_regs("%[^%]*%"))) {
             foreach ($vars as $curly_pattern) {
                 // $curly_pattern contatins %pattern% in replacement string
                 $pattern = mb_substr($curly_pattern, 1, mb_strlen($curly_pattern) - 2);
                 // avoid recursive loop
                 if ($pattern != $str) {
                     if (isset($variables[$lang][$pattern])) {
                         $pattern_replacement = $variables[$lang][$pattern];
                         $langstr = mb_ereg_replace($curly_pattern, $pattern_replacement, $langstr);
                     }
                 }
             }
         }
     }
     return $langstr;
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:21,代码来源:translationHandler.class.php

示例14: mb_ereg_search_getregs

$r = mb_ereg_search_getregs();
// get first result
var_dump($r === array("PrÜÝ" . "fung"));
var_dump(mb_ereg_search_setpos(15));
$r = mb_ereg_search_regs();
// get next result
var_dump($r == array("pÜ"));
$str = "PrÜÝ" . "fung abc pÜ";
mb_regex_encoding("UTF-8");
mb_ereg_search_init($str);
$r = mb_ereg_search_regs("abc", "ms");
var_dump($r);
$str = "PrÜÝ" . "fung abc pÜ";
$reg = "\\w+";
mb_regex_encoding("UTF-8");
mb_ereg_search_init($str, $reg);
$r = mb_ereg_search();
$r = mb_ereg_search_getregs();
// get first result
var_dump($r === array("PrÜÝ" . "fung"));
$date = "1973-04-30";
mb_ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs);
var_dump($regs[3]);
var_dump($regs[2]);
var_dump($regs[1]);
var_dump($regs[0]);
$pattern = "(>[^<]*)(suffix)";
$replacement = "\\1<span class=\"search\">\\2</span>";
$body = ">whateversuffix";
$body = mb_eregi_replace($pattern, $replacement, $body);
var_dump($body);
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:mb_ereg.php

示例15: 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


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