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


PHP mb_ereg_match函数代码示例

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


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

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

示例2: addLink

 public function addLink($userId, $href, $title, $description, $thumbnailUrl, $text = null, $addToFeed = true)
 {
     if (!$this->isActive()) {
         return null;
     }
     OW::getCacheManager()->clean(array(LinkDao::CACHE_TAG_LINK_COUNT));
     $service = LinkService::getInstance();
     $url = mb_ereg_match('^http(s)?:\\/\\/', $href) ? $href : 'http://' . $href;
     $link = new Link();
     $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => OW::getUser()->getId());
     $privacy = OW::getEventManager()->getInstance()->call('plugin.privacy.get_privacy', $eventParams);
     if (!empty($privacy)) {
         $link->setPrivacy($privacy);
     }
     $link->setUserId($userId);
     $link->setTimestamp(time());
     $link->setUrl($url);
     $link->setDescription(strip_tags($description));
     $title = empty($title) ? $text : $title;
     $link->setTitle(strip_tags($title));
     $service->save($link);
     if ($addToFeed) {
         $content = array("format" => null, "vars" => array("status" => $text));
         if (!empty($thumbnailUrl)) {
             $content["format"] = "image_content";
             $content["vars"]["image"] = $thumbnailUrl;
             $content["vars"]["thumbnail"] = $thumbnailUrl;
         }
         //Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'links', 'entityType' => 'link', 'entityId' => $link->getId(), 'userId' => $link->getUserId()), array("content" => $content));
         OW::getEventManager()->trigger($event);
     }
     return $link->id;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:34,代码来源:links_bridge.php

示例3: isValid

 public function isValid($value)
 {
     if (!mb_ereg_match($this->getValidateRegex(), $value)) {
         return false;
     }
     $num_value = $this->getValue($value);
     return $this->min <= $num_value && $num_value <= $this->max;
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:8,代码来源:Numeric.php

示例4: process

 /**
  * @inheritdoc
  */
 public function process(LanguageInterface $language, $item)
 {
     $alphabet = implode('', $language->getAlphabet());
     $wordPattern = "^[{$alphabet}]+\$";
     $options = $this->getOptions();
     $itemPassed = mb_ereg_match($wordPattern, $item, $options);
     return $itemPassed;
 }
开发者ID:kolyunya,项目名称:wiki-parser,代码行数:11,代码来源:AlphabetFilter.php

示例5: searchbooks

 public function searchbooks()
 {
     if ($this->request->is('post')) {
         if (empty($this->request->data)) {
             $this->redirect('/posts/index');
             $this->Session->setFlash('formを入力してください');
         }
         $title = $this->request->data['Book']['title'];
         $author = $this->request->data['Book']['author'];
         if (mb_ereg_match("^(\\s| )+\$", $title)) {
             if (mb_ereg_match("^(\\s| )+\$", $author)) {
                 $this->Session->setFlash("ちゃんと入力してください");
                 $this->redirect('/posts/index');
             }
         }
         $title = preg_replace("/( | )/", "", $title);
         $author = preg_replace("/( | )/", "", $author);
         if (!empty($title) && !empty($author)) {
             $data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'title' => $title, 'author' => $author, 'hits' => 25, 'page' => 1);
         } else {
             if (!empty($title)) {
                 $data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'title' => $title, 'hits' => 25, 'page' => 1);
             } else {
                 if (!empty($author)) {
                     $data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'author' => $author, 'hits' => 25, 'page' => 1);
                 } else {
                     $this->Session->setFlash('ちゃんと入力してください');
                     $this->redirect('/posts/index');
                 }
             }
         }
         $items = parent::search($data);
         if (empty($items)) {
             $this->Session->setFlash("該当する本が見つかりませんでした");
             $this->redirect('/posts/index');
         }
         if ($items['count'] == 0) {
             $this->Session->setFlash('該当する本が見つかりませんでした');
             $this->redirect($this->referer());
         }
         $count = $items['count'];
         $page = $items['page'];
         $hits = $items['hits'];
         $first = $items['first'];
         $tmppage = ceil($count / 25);
         $items['count'] = null;
         $items['page'] = null;
         $items['hits'] = null;
         $items['first'] = null;
         $this->set('data', $data);
         $this->set('items', $items);
         $this->set('count', $count);
         $this->set('tmppage', $tmppage);
         $this->set('page', $page);
         $this->set('hits', $hits);
         $this->set('first', $first);
     }
 }
开发者ID:takuyahasegawahterry,项目名称:cakephp,代码行数:58,代码来源:BooksController.php

示例6: setText

 public function setText($value)
 {
     if ($value != '') {
         if (!mb_ereg_match(REGEX_STATPIC_TEXT, $value)) {
             return false;
         }
     }
     return $this->reUser->setValue('statpic_text', $value);
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:9,代码来源:statpic.class.php

示例7: vxCleanKijijiTitle

 public function vxCleanKijijiTitle($title)
 {
     if (mb_ereg_match('最新的客齐集广告', $title)) {
         mb_ereg('最新的客齐集广告 所在地:(.+) 分类:(.+)', $title, $m);
         return '最新的客齐集广告' . ' - ' . $m[1] . ' - ' . $m[2];
     } else {
         return $title;
     }
 }
开发者ID:biaodianfu,项目名称:project-babel,代码行数:9,代码来源:ChannelCore.php

示例8: processLine

 /**
  * (non-PHPdoc)
  * @see JSONImportStateInterface::processLine()
  */
 public function processLine($line)
 {
     // Change state
     if (mb_ereg_match("\"export\"\\:[ ]*\\{.*", $line)) {
         return new JSONImportStateMetaData($this->importData);
     } else {
         return $this;
     }
 }
开发者ID:iweave,项目名称:unmark,代码行数:13,代码来源:JSONImportStateStart.php

示例9: space_only

 function space_only($field = array())
 {
     foreach ($field as $name => $value) {
     }
     if (mb_ereg_match("^(\\s| )+\$", $value)) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:takuyahasegawahterry,项目名称:cakephp,代码行数:10,代码来源:AppModel.php

示例10: checkCaptcha

function checkCaptcha($id, $string)
{
    global $CAPTCHA_CONFIG;
    $captcha =& new b2evo_captcha($CAPTCHA_CONFIG);
    // additional check ... id and string can only contain [a-f0-9]
    if (mb_ereg_match('^[0-9a-f]{32}$', $id) == false) {
        return false;
    }
    if ($captcha->validate_submit($id . '.jpg', $string) == 1) {
        return true;
    } else {
        return false;
    }
}
开发者ID:RH-Code,项目名称:opencaching,代码行数:14,代码来源:captcha.inc.php

示例11: processLine

 /**
  * (non-PHPdoc)
  * @see JSONImportStateInterface::processLine()
  */
 public function processLine($line)
 {
     // Change state
     if (mb_ereg_match("\"marks\"\\:[ ]*\\[.*", $line)) {
         return new JSONImportStateMarks($this->importData);
     } else {
         // Strip trailing comma and simulate JSON
         $jsonLine = '{' . mb_ereg_replace("\\,[ ]*\$", '', $line) . '}';
         $decodedObject = json_decode($jsonLine);
         foreach ($decodedObject as $key => $value) {
             if (!isset($this->importData['meta'])) {
                 $this->importData['meta'] = array();
             }
             $this->importData['meta'][$key] = $value;
         }
         return $this;
     }
 }
开发者ID:iweave,项目名称:unmark,代码行数:22,代码来源:JSONImportStateMetaData.php

示例12: processLine

 /**
  * (non-PHPdoc)
  *
  * @see JSONImportStateInterface::processLine()
  */
 public function processLine($line)
 {
     // Finished
     if (mb_ereg_match("^[ ]*\\][ ]*\$", $line)) {
         return $this->importData;
     } else {
         // Strip trailing comma and simulate JSON
         $jsonLine = mb_ereg_replace("\\,[ ]*\$", '', $line);
         $decodedMark = json_decode($jsonLine);
         $importResult = $this->CI->mark_import->importMark($decodedMark);
         $this->importData['result']['total']++;
         $this->importData['result'][$importResult['result']]++;
         if (self::RETURN_DETAILS && (!self::RETURN_DETAILS_ERRORS_ONLY || $importResult['result'] === self::RESULT_FAILED || !empty($importResult['warnings']))) {
             $this->importData['details'][$decodedMark->mark_id] = $importResult;
         }
         return $this;
     }
 }
开发者ID:iweave,项目名称:unmark,代码行数:23,代码来源:JSONImportStateMarks.php

示例13: normalizarNome

/**
 * @param string $nome O nome a ser normalizado
 * @return string O nome devidamente normalizado
 */
function normalizarNome($nome)
{
    $nome = mb_ereg_replace(self::NN_PONTO, self::NN_PONTO_ESPACO, $nome);
    $nome = mb_ereg_replace(self::NN_REGEX_MULTIPLOS_ESPACOS, self::NN_ESPACO, $nome);
    $nome = ucwords(strtolower($nome));
    // alterando essa linha pela anterior funciona para acentos
    $partesNome = mb_split(self::NN_ESPACO, $nome);
    $excecoes = array('de', 'do', 'di', 'da', 'dos', 'das', 'dello', 'della', 'dalla', 'dal', 'del', 'e', 'em', 'na', 'no', 'nas', 'nos', 'van', 'von', 'y', 'der');
    for ($i = 0; $i < count($partesNome); ++$i) {
        if (mb_ereg_match(self::NN_REGEX_NUMERO_ROMANO, mb_strtoupper($partesNome[$i]))) {
            $partesNome[$i] = mb_strtoupper($partesNome[$i]);
        }
        foreach ($excecoes as $excecao) {
            if (mb_strtolower($partesNome[$i]) == mb_strtolower($excecao)) {
                $partesNome[$i] = $excecao;
            }
        }
    }
    $nomeCompleto = implode(self::NN_ESPACO, $partesNome);
    return addslashes($nomeCompleto);
}
开发者ID:CGPUCPR,项目名称:SwB-2nd,代码行数:25,代码来源:form_sisdoc_helper.php

示例14: filter

 /**
  * Enter description here...
  *
  * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
  * @link http://docs.jquery.com/Traversing/filter
  */
 public function filter($selectors, $_skipHistory = false)
 {
     if ($selectors instanceof Callback or $selectors instanceof Closure) {
         return $this->filterCallback($selectors, $_skipHistory);
     }
     if (!$_skipHistory) {
         $this->elementsBackup = $this->elements;
     }
     $notSimpleSelector = array(' ', '>', '~', '+', '/');
     if (!is_array($selectors)) {
         $selectors = $this->parseSelector($selectors);
     }
     if (!$_skipHistory) {
         $this->debug(array("Filtering:", $selectors));
     }
     $finalStack = array();
     foreach ($selectors as $selector) {
         $stack = array();
         if (!$selector) {
             break;
         }
         // avoid first space or /
         if (in_array($selector[0], $notSimpleSelector)) {
             $selector = array_slice($selector, 1);
         }
         // PER NODE selector chunks
         foreach ($this->stack() as $node) {
             $break = false;
             foreach ($selector as $s) {
                 if (!$node instanceof DOMELEMENT) {
                     // all besides DOMElement
                     if ($s[0] == '[') {
                         $attr = trim($s, '[]');
                         if (mb_strpos($attr, '=')) {
                             list($attr, $val) = explode('=', $attr);
                             if ($attr == 'nodeType' && $node->nodeType != $val) {
                                 $break = true;
                             }
                         }
                     } else {
                         $break = true;
                     }
                 } else {
                     // DOMElement only
                     // ID
                     if ($s[0] == '#') {
                         if ($node->getAttribute('id') != substr($s, 1)) {
                             $break = true;
                         }
                         // CLASSES
                     } else {
                         if ($s[0] == '.') {
                             if (!$this->matchClasses($s, $node)) {
                                 $break = true;
                             }
                             // ATTRS
                         } else {
                             if ($s[0] == '[') {
                                 // strip side brackets
                                 $attr = trim($s, '[]');
                                 if (mb_strpos($attr, '=')) {
                                     list($attr, $val) = explode('=', $attr);
                                     $val = self::unQuote($val);
                                     if ($attr == 'nodeType') {
                                         if ($val != $node->nodeType) {
                                             $break = true;
                                         }
                                     } else {
                                         if ($this->isRegexp($attr)) {
                                             $val = extension_loaded('mbstring') && phpQuery::$mbstringSupport ? quotemeta(trim($val, '"\'')) : preg_quote(trim($val, '"\''), '@');
                                             // switch last character
                                             switch (substr($attr, -1)) {
                                                 // quotemeta used insted of preg_quote
                                                 // http://code.google.com/p/phpquery/issues/detail?id=76
                                                 case '^':
                                                     $pattern = '^' . $val;
                                                     break;
                                                 case '*':
                                                     $pattern = '.*' . $val . '.*';
                                                     break;
                                                 case '$':
                                                     $pattern = '.*' . $val . '$';
                                                     break;
                                             }
                                             // cut last character
                                             $attr = substr($attr, 0, -1);
                                             $isMatch = extension_loaded('mbstring') && phpQuery::$mbstringSupport ? mb_ereg_match($pattern, $node->getAttribute($attr)) : preg_match("@{$pattern}@", $node->getAttribute($attr));
                                             if (!$isMatch) {
                                                 $break = true;
                                             }
                                         } else {
                                             if ($node->getAttribute($attr) != $val) {
                                                 $break = true;
                                             }
//.........这里部分代码省略.........
开发者ID:limi58,项目名称:fetchJD,代码行数:101,代码来源:phpQueryObject.php

示例15: requestHandler

 private function requestHandler($query, $types)
 {
     $result = array('msg' => JText::_('PED_CITY_COUNTRY_NOT_FOUND'));
     // Инициализация структуры массива ответа
     foreach ($types as $t) {
         $result[$t] = array('length' => 0);
     }
     // Подготовка строк для поиска
     $query = mb_strtolower($query, 'utf-8');
     mb_regex_encoding('utf-8');
     $qList = mb_split("[^\\w]", $query);
     // Отбрасывание слов менее 3х букв
     foreach ($qList as $k => $query) {
         if (mb_strlen($query, 'utf-8') < 3) {
             unset($qList[$k]);
         }
     }
     // Проверка налиция шаблонов для поиска
     if (!count($qList)) {
         $result['msg'] = JText::_('PED_SMALL_QUERY');
         return $result;
     }
     // Получение списка городов/стран
     $list = $this->getDestinations();
     // Обрбаотка каждого типа поля
     foreach ($types as &$type) {
         // Поиск совпадений по списку городов/стран
         // и заполнение массива с результатами
         foreach ($list[$type] as $k => &$v) {
             // Поиск совпадений для каждой части запроса
             foreach ($qList as &$q) {
                 if (mb_ereg_match(".*\\b" . $q . ".*", mb_strtolower($v, 'utf-8'))) {
                     $result[$type][$k] = $v;
                 }
             }
         }
         // Сортировка результатов и удаление дубликатов
         $result[$type] = array_unique($result[$type]);
         asort($result[$type]);
         $result[$type]['length'] = count($result[$type]) - 1;
     }
     return $result;
 }
开发者ID:arkane0906,项目名称:lasercut-bootstrap,代码行数:43,代码来源:edost.php


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