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


PHP preg_quote函数代码示例

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


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

示例1: configure

 /**
  * Configure after successfull mount.
  *
  * @return void
  * @author Dmitry (dio) Levashov
  **/
 protected function configure()
 {
     $this->aroot = realpath($this->root);
     $root = $this->stat($this->root);
     if ($this->options['quarantine']) {
         $this->attributes[] = array('pattern' => '~^' . preg_quote(DIRECTORY_SEPARATOR . $this->options['quarantine']) . '$~', 'read' => false, 'write' => false, 'locked' => true, 'hidden' => true);
     }
     // chek thumbnails path
     if ($this->options['tmbPath']) {
         $this->options['tmbPath'] = strpos($this->options['tmbPath'], DIRECTORY_SEPARATOR) === false ? $this->root . DIRECTORY_SEPARATOR . $this->options['tmbPath'] : $this->_normpath($this->options['tmbPath']);
     }
     parent::configure();
     // if no thumbnails url - try detect it
     if ($root['read'] && !$this->tmbURL && $this->URL) {
         if (strpos($this->tmbPath, $this->root) === 0) {
             $this->tmbURL = $this->URL . str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1));
             if (preg_match("|[^/?&=]\$|", $this->tmbURL)) {
                 $this->tmbURL .= '/';
             }
         }
     }
     // check quarantine dir
     if (!empty($this->options['quarantine'])) {
         $this->quarantine = $this->root . DIRECTORY_SEPARATOR . $this->options['quarantine'];
         if (!is_dir($this->quarantine) && !$this->_mkdir($this->root, $this->options['quarantine']) || !is_writable($this->quarantine)) {
             $this->archivers['extract'] = array();
             $this->disabled[] = 'extract';
         }
     } else {
         $this->archivers['extract'] = array();
         $this->disabled[] = 'extract';
     }
 }
开发者ID:rb26,项目名称:zenphoto,代码行数:39,代码来源:elFinderVolumeLocalFileSystem.class.php

示例2: parseLine

 /**
  * Parse of HTML line
  *
  * @param string $line
  * @param array $tags [optional]
  * @return \axy\min\html\helpers\ParseLineResult
  */
 public static function parseLine($line, array $tags = null)
 {
     $result = new ParseLineResult('');
     while ($line !== '') {
         if (!preg_match('~^(?<before>.*?)\\<(?<tag>/?[a-z0-9-]+)(?<attr>.*?)?>(?<after>.*?)$~is', $line, $matches)) {
             $result->append($line);
             break;
         }
         $tag = $matches['tag'];
         $after = $matches['after'];
         $tagL = strtolower($matches['tag']);
         $result->append($matches['before'] . '<' . $tag . $matches['attr'] . '>');
         if (isset($tags[$tagL])) {
             $pattern = '~^(?<before>.*?)(?<tag></' . preg_quote($tagL) . '>)(?<after>.*?)$~is';
             if (!preg_match($pattern, $after, $matches)) {
                 $result->tag = $tagL;
                 $result->after = $after;
                 break;
             }
             $content = $matches['before'];
             $content = self::process($content, $tags[$tagL]);
             $result->append($content . $matches['tag']);
             $line = $matches['after'];
         } else {
             $line = $after;
         }
     }
     if (!$result->tag) {
         $result->before = rtrim($result->before);
     }
     return $result;
 }
开发者ID:axypro,项目名称:min-html,代码行数:39,代码来源:Parser.php

示例3: test_interactive

 public function test_interactive()
 {
     // Create a gapselect question.
     $q = test_question_maker::make_question('calculated');
     $q->hints = array(new question_hint(1, 'This is the first hint.', FORMAT_HTML), new question_hint(2, 'This is the second hint.', FORMAT_HTML));
     $this->start_attempt_at_question($q, 'interactive', 3, 1);
     $values = $q->vs->get_values();
     $this->assertEquals($values, $q->datasetloader->load_values(1));
     // Check the initial state.
     $this->check_current_state(question_state::$todo);
     $this->check_current_mark(null);
     $this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_does_not_contain_validation_error_expectation(), $this->get_does_not_contain_try_again_button_expectation(), $this->get_no_hint_visible_expectation());
     // Submit blank.
     $this->process_submission(array('-submit' => 1, 'answer' => ''));
     // Verify.
     $this->check_current_state(question_state::$invalid);
     $this->check_current_mark(null);
     $this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_contains_validation_error_expectation(), $this->get_does_not_contain_try_again_button_expectation(), $this->get_no_hint_visible_expectation());
     // Sumit something that does not look like a number.
     $this->process_submission(array('-submit' => 1, 'answer' => 'newt'));
     // Verify.
     $this->check_current_state(question_state::$invalid);
     $this->check_current_mark(null);
     $this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_contains_validation_error_expectation(), new question_pattern_expectation('/' . preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'), $this->get_does_not_contain_try_again_button_expectation(), $this->get_no_hint_visible_expectation());
     // Now get it right.
     $this->process_submission(array('-submit' => 1, 'answer' => $values['a'] + $values['b']));
     // Verify.
     $this->check_current_state(question_state::$gradedright);
     $this->check_current_mark(3);
     $this->check_current_output($this->get_contains_mark_summary(3), $this->get_does_not_contain_submit_button_expectation(), $this->get_contains_correct_expectation(), $this->get_does_not_contain_validation_error_expectation(), $this->get_no_hint_visible_expectation());
 }
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:walkthrough_test.php

示例4: __construct

 public function __construct(ProcessorInterface $processor = null, $startSep = '---', $endSep = '---')
 {
     $this->startSep = $startSep;
     $this->endSep = $endSep;
     $this->processor = $processor ?: new YamlProcessor();
     $this->regexp = '{^(?:' . preg_quote($startSep) . ")[\r\n|\n]*(.*?)[\r\n|\n]+(?:" . preg_quote($endSep) . ")[\r\n|\n]*(.*)\$}s";
 }
开发者ID:webuni,项目名称:front-matter,代码行数:7,代码来源:FrontMatter.php

示例5: getColumnFromTable

 /**
  * Get column name
  * @param string $name
  * @return string
  */
 protected function getColumnFromTable($name)
 {
     if ($this->table != '%s' && preg_match('(^' . str_replace('%s', '(.*)', preg_quote($this->table)) . '$)', $name, $match)) {
         return $match[1];
     }
     return $name;
 }
开发者ID:sim2github,项目名称:notorm,代码行数:12,代码来源:StructureConvention.php

示例6: hookActionAdminControllerSetMedia

 public function hookActionAdminControllerSetMedia($params)
 {
     $admin_webpath = str_ireplace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_);
     $admin_webpath = preg_replace('/^' . preg_quote(DIRECTORY_SEPARATOR, '/') . '/', '', $admin_webpath);
     $this->context->controller->addJS(array(_PS_JS_DIR_ . 'vendor/d3.v3.min.js', __PS_BASE_URI__ . $admin_webpath . '/themes/' . $this->context->employee->bo_theme . '/js/vendor/nv.d3.min.js'));
     $this->context->controller->addCSS(__PS_BASE_URI__ . $admin_webpath . '/themes/' . $this->context->employee->bo_theme . '/css/vendor/nv.d3.css');
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:7,代码来源:graphnvd3.php

示例7: __construct

 /**
  * Constructor.
  *
  * @param \Iterator $iterator    The Iterator to filter
  * @param array     $directories An array of directories to exclude
  */
 public function __construct(\Iterator $iterator, array $directories)
 {
     foreach ($directories as $directory) {
         $this->patterns[] = '#(^|/)' . preg_quote($directory, '#') . '(/|$)#';
     }
     parent::__construct($iterator);
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:13,代码来源:ExcludeDirectoryFilterIterator.php

示例8: clean

 public static function clean($url, $toLower = true, $spacer = '-')
 {
     if ($toLower == true) {
         $url = strtolower($url);
     }
     // International umlauts
     $url = str_replace(array('á', 'à', 'â', 'Á', 'À', 'Â'), 'a', $url);
     $url = str_replace(array('ç', 'Ç'), 'c', $url);
     $url = str_replace(array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ë', 'Ê'), 'e', $url);
     $url = str_replace(array('í', 'ì', 'î', 'ï', 'Í', 'Ì', 'Î', 'Ï'), 'i', $url);
     $url = str_replace(array('ó', 'ò', 'ô', 'Ó', 'Ò', 'Ô'), 'o', $url);
     $url = str_replace(array('ú', 'ù', 'û', 'Ú', 'Ù', 'Û'), 'u', $url);
     // German umlauts
     $url = str_replace(array('ä', 'Ä'), 'ae', $url);
     $url = str_replace(array('ö', 'Ö'), 'oe', $url);
     $url = str_replace(array('ü', 'Ü'), 'ue', $url);
     $url = str_replace(array('ß'), 'ss', $url);
     // Replace some special chars with delimiter
     $url = preg_replace('/[\\+\\s\\r\\n\\t]+/', $spacer, $url);
     // Replace multiple delimiter chars with only one char
     $url = preg_replace('/[' . preg_quote($spacer, '/') . ']+/', $spacer, $url);
     // Remove html and other special chars
     $url = preg_replace(array('/<[^>]*>/', '/[^a-z0-9\\-\\._' . preg_quote($spacer, '/') . ']/i'), '', $url);
     return $url;
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:25,代码来源:class.URI.php

示例9: __construct

 function __construct($connect_options)
 {
     $this->url = $connect_options['url'];
     $this->is_require_auth = $connect_options['require_auth'];
     if ($this->is_require_auth) {
         $this->login = $connect_options['login'];
         $this->password = $connect_options['password'];
     }
     $this->connect_timeout = isset($connect_options['connect_timeout']) ? $connect_options['connect_timeout'] : 5;
     $this->timeout = isset($connect_options['timeout']) ? $connect_options['timeout'] : 5;
     $this->exclude = explode(';', $connect_options['exclude']);
     $parse_format = $connect_options['parse_format'];
     $this->matches = preg_split('/%\\w+/u', $parse_format);
     $matches_symbol = array();
     preg_match_all('/(%\\w+)/', $parse_format, $matches_symbol);
     $symbol = reset($matches_symbol[0]);
     $this->regex = '/';
     $this->tags = array();
     foreach ($this->matches as $key => $value) {
         if (!empty($value)) {
             $this->regex .= preg_quote($value);
             continue;
         }
         $this->tags[] = substr($symbol, 1);
         $symbol = next($matches_symbol[0]);
         if ($symbol === false) {
             $this->regex .= '(.+)';
             break;
         } else {
             $this->regex .= '(.+?)';
         }
     }
     $this->regex .= '/u';
 }
开发者ID:rodnover55,项目名称:last_tracks_shoutcast,代码行数:34,代码来源:last_track_request.php

示例10: apply

 /**
  * With lots of various rules we created 4 various rulesets for operators. If one
  * of the tokens or content is found we use the given regex on the joined array.
  *
  * @param  Testable $testable The testable object
  * @return void
  */
 public function apply($testable, array $config = array())
 {
     $tokens = $testable->tokens();
     foreach ($this->inspector as $inspector) {
         if (isset($inspector['tokens'])) {
             $byToken = $testable->findAll($inspector['tokens']);
         } else {
             $byToken = array();
         }
         if (isset($inspector['content'])) {
             $byContent = $testable->findAllContent($inspector['content']);
         } else {
             $byContent = array();
         }
         foreach (array_merge($byToken, $byContent) as $id) {
             $token = $tokens[$id];
             $isPHP = $testable->isPHP($token['line']);
             if ($isPHP && empty($token['isString'])) {
                 $pattern = String::insert($inspector['regex'], array('content' => preg_quote($token['content'], "/")));
                 $firstId = $id - $inspector['relativeTokens']['before'];
                 $firstId = $firstId < 0 ? 0 : $firstId;
                 $length = $inspector['relativeTokens']['length'];
                 $inspectTokens = array_slice($tokens, $firstId, $length);
                 $html = null;
                 foreach ($inspectTokens as $htmlToken) {
                     $html .= $htmlToken['content'];
                 }
                 if (preg_match($pattern, $html) === 0) {
                     $this->addViolation(array('message' => String::insert($inspector['message'], $token), 'line' => $token['line']));
                 }
             }
         }
     }
 }
开发者ID:unionofrad,项目名称:li3_quality,代码行数:41,代码来源:OperatorSpacing.php

示例11: censorword_cache

 /**
  * 生成敏感词缓存 filter:替换关键字,banned:禁止关键字,mod:审核关键字
  * @return string 关键词数据
  */
 public function censorword_cache()
 {
     $banned = $mod = array();
     $bannednum = $modnum = 0;
     $data = array('filter' => array(), 'banned' => '', 'mod' => '');
     foreach ($this->select() as $censor) {
         if (preg_match('/^\\/(.+?)\\/$/', $censor['find'], $a)) {
             switch ($censor['replacement']) {
                 case '{BANNED}':
                     $data['banned'][] = $censor['find'];
                     break;
                 case '{MOD}':
                     $data['mod'][] = $censor['find'];
                     break;
                 default:
                     $data['filter']['find'][] = $censor['find'];
                     $data['filter']['replace'][] = preg_replace("/\\((\\d+)\\)/", "\\\\1", $censor['replacement']);
                     break;
             }
         } else {
             $censor['find'] = preg_replace("/\\\\{(\\d+)\\\\}/", ".{0,\\1}", preg_quote($censor['find'], '/'));
             switch ($censor['replacement']) {
                 case '{BANNED}':
                     $banned[] = $censor['find'];
                     $bannednum++;
                     if ($bannednum == 1000) {
                         $data['banned'][] = '/(' . implode('|', $banned) . ')/i';
                         $banned = array();
                         $bannednum = 0;
                     }
                     break;
                 case '{MOD}':
                     $mod[] = $censor['find'];
                     $modnum++;
                     if ($modnum == 1000) {
                         $data['mod'][] = '/(' . implode('|', $mod) . ')/i';
                         $mod = array();
                         $modnum = 0;
                     }
                     break;
                 default:
                     $data['filter']['find'][] = '/' . $censor['find'] . '/i';
                     $data['filter']['replace'][] = $censor['replacement'];
                     break;
             }
         }
     }
     if ($banned) {
         $data['banned'][] = '/(' . implode('|', $banned) . ')/i';
     }
     if ($mod) {
         $data['mod'][] = '/(' . implode('|', $mod) . ')/i';
     }
     //过滤关键词数据
     F("Censor_words", $data);
     //分类数据
     $typedata = M("Terms")->where(array("module" => "censor"))->select();
     F("Censor_type", $typedata);
     return $data;
 }
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:64,代码来源:CensorModel.class.php

示例12: quote

 /**
  * Quote regular expression characters.
  *
  * @param string $value
  * @param string $delimiter
  *
  * @return string
  */
 public function quote($value, $delimiter = '/')
 {
     if (!isset($value)) {
         return null;
     }
     return preg_quote($value, $delimiter);
 }
开发者ID:vgrish,项目名称:twiggy,代码行数:15,代码来源:twiggyextensionpcre.class.php

示例13: testFetchButton

 /**
  * Tests the fetchButton method
  *
  * @return  void
  *
  * @since   3.0
  */
 public function testFetchButton()
 {
     $name = 'jdotorg';
     $text = 'Joomla.org';
     $url = 'http://www.joomla.org';
     $this->assertRegExp('#<button onclick="location.href=\'' . preg_quote($url, '#') . '\';" class="btn btn-small">\\s*' . '<span class="icon-' . preg_quote($name, '#') . '"></span>\\s+' . preg_quote($text, '#') . '\\s*' . '</button>\\s*#', $this->object->fetchButton('Link', $name, $text, $url));
 }
开发者ID:n3t,项目名称:joomla-cms,代码行数:14,代码来源:JToolbarButtonLinkTest.php

示例14: get_homepage_link

 /**
  * Get the full form (e.g. /home/) relative link to the home page for the current HTTP_HOST value. Note that the
  * link is trimmed of leading and trailing slashes before returning to ensure consistency.
  *
  * @return string
  */
 public static function get_homepage_link()
 {
     if (!self::$cached_homepage_link) {
         // TODO Move to 'homepagefordomain' module
         if (class_exists('HomepageForDomainExtension')) {
             $host = str_replace('www.', null, $_SERVER['HTTP_HOST']);
             $SQL_host = Convert::raw2sql($host);
             $candidates = DataObject::get('SiteTree', "\"HomepageForDomain\" LIKE '%{$SQL_host}%'");
             if ($candidates) {
                 foreach ($candidates as $candidate) {
                     if (preg_match('/(,|^) *' . preg_quote($host) . ' *(,|$)/', $candidate->HomepageForDomain)) {
                         self::$cached_homepage_link = trim($candidate->RelativeLink(true), '/');
                     }
                 }
             }
         }
         if (!self::$cached_homepage_link) {
             // TODO Move to 'translatable' module
             if (class_exists('Translatable') && Object::has_extension('SiteTree', 'Translatable') && ($link = Translatable::get_homepage_link_by_locale(Translatable::get_current_locale()))) {
                 self::$cached_homepage_link = $link;
             } else {
                 self::$cached_homepage_link = self::get_default_homepage_link();
             }
         }
     }
     return self::$cached_homepage_link;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:33,代码来源:RootURLController.php

示例15: fnmatch

 function fnmatch($pattern, $string, $flags = 0)
 {
     $modifiers = null;
     $transforms = array('\\*' => '.*', '\\?' => '.', '\\[\\!' => '[^', '\\[' => '[', '\\]' => ']', '\\.' => '\\.', '\\' => '\\\\');
     // Forward slash in string must be in pattern:
     if ($flags & FNM_PATHNAME) {
         $transforms['\\*'] = '[^/]*';
     }
     // Back slash should not be escaped:
     if ($flags & FNM_NOESCAPE) {
         unset($transforms['\\']);
     }
     // Perform case insensitive match:
     if ($flags & FNM_CASEFOLD) {
         $modifiers .= 'i';
     }
     // Period at start must be the same as pattern:
     if ($flags & FNM_PERIOD) {
         if (strpos($string, '.') === 0 && strpos($pattern, '.') !== 0) {
             return false;
         }
     }
     $pattern = '~^' . strtr(preg_quote($pattern, '~'), $transforms) . '$~' . $modifiers;
     return (bool) preg_match($pattern, $string);
 }
开发者ID:niko-lgdcom,项目名称:archives,代码行数:25,代码来源:compat.php


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