• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP preg_match_all函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addComplexType

 /**
  * Add a complex type by recursivly using all the class properties fetched via Reflection.
  *
  * @param  string $type Name of the class to be specified
  * @return string XSD Type for the given PHP type
  */
 public function addComplexType($type)
 {
     if (!class_exists($type)) {
         throw new \Zend\Soap\WSDL\Exception(sprintf('Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type));
     }
     $dom = $this->getContext()->toDomDocument();
     $class = new \ReflectionClass($type);
     $complexType = $dom->createElement('xsd:complexType');
     $complexType->setAttribute('name', $type);
     $all = $dom->createElement('xsd:all');
     foreach ($class->getProperties() as $property) {
         if ($property->isPublic() && preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) {
             /**
              * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
              * node for describing other classes used as attribute types for current class
              */
             $element = $dom->createElement('xsd:element');
             $element->setAttribute('name', $property->getName());
             $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
             $all->appendChild($element);
         }
     }
     $complexType->appendChild($all);
     $this->getContext()->getSchema()->appendChild($complexType);
     $this->getContext()->addType($type);
     return "tns:{$type}";
 }
开发者ID:hjr3,项目名称:zf2,代码行数:33,代码来源:DefaultComplexType.php


示例2: convertDateMomentToPhp

 public static function convertDateMomentToPhp($format)
 {
     $tokens = ["M" => "n", "Mo" => "nS", "MM" => "m", "MMM" => "M", "MMMM" => "F", "D" => "j", "Do" => "jS", "DD" => "d", "DDD" => "z", "DDDo" => "zS", "DDDD" => "zS", "d" => "w", "do" => "wS", "dd" => "D", "ddd" => "D", "dddd" => "l", "e" => "w", "E" => "N", "w" => "W", "wo" => "WS", "ww" => "W", "W" => "W", "Wo" => "WS", "WW" => "W", "YY" => "y", "YYYY" => "Y", "gg" => "o", "gggg" => "o", "GG" => "o", "GGGG" => "o", "A" => "A", "a" => "a", "H" => "G", "HH" => "H", "h" => "g", "hh" => "h", "m" => "i", "mm" => "i", "s" => "s", "ss" => "s", "S" => "", "SS" => "", "SSS" => "", "z or zz" => "T", "Z" => "P", "ZZ" => "O", "X" => "U", "LT" => "g:i A", "L" => "m/d/Y", "l" => "n/j/Y", "LL" => "F jS Y", "ll" => "M j Y", "LLL" => "F js Y g:i A", "lll" => "M j Y g:i A", "LLLL" => "l, F jS Y g:i A", "llll" => "D, M j Y g:i A"];
     // find all tokens from string, using regular expression
     $regExp = "/(\\[[^\\[]*\\])|(\\\\)?(LT|LL?L?L?|l{1,4}|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/";
     $matches = array();
     preg_match_all($regExp, $format, $matches);
     //  if there is no match found then return the string as it is
     //  TODO: might return escaped string
     if (empty($matches) || is_array($matches) === false) {
         return $format;
     }
     //  to match with extracted tokens
     $momentTokens = array_keys($tokens);
     $phpMatches = array();
     //  ----------------------------------
     foreach ($matches[0] as $id => $match) {
         // if there is a matching php token in token list
         if (in_array($match, $momentTokens)) {
             // use the php token instead
             $string = $tokens[$match];
         } else {
             $string = $match;
         }
         $phpMatches[$id] = $string;
     }
     // join and return php specific tokens
     return implode("", $phpMatches);
 }
开发者ID:rocketyang,项目名称:hasscms-app,代码行数:29,代码来源:FormatConverter.php


示例3: imitateLogin

 public function imitateLogin($sdutnum, $password)
 {
     //模拟登录
     $cookie_jar = dirname(__FILE__) . "/cookie";
     $urlLogin = "http://222.206.65.12/reader/redr_verify.php";
     $post = "number={$sdutnum}&passwd={$password}&select=cert_no&returnUrl=";
     $this->curl->login_post($urlLogin, $cookie_jar, $post);
     //抓取内容
     $urlBook = "http://222.206.65.12/reader/book_lst.php";
     $html = $this->curl->get_content($urlBook, $cookie_jar);
     $loginReg = "/logout/";
     $BookReg = "/<td.*/";
     $buttonReg = "/<div\\sid=\"\\w\"><input.*\\/>/";
     $nameReg = '/height="11" \\/>.*logout/';
     $numReg = '/<p>.*<b/';
     //book number
     preg_match_all($loginReg, $html, $isLogin);
     //to judgment whether login
     preg_match_all($BookReg, $html, $bookArray);
     preg_match_all($buttonReg, $html, $buttonArray);
     preg_match_all($nameReg, $html, $nameArray);
     //username
     preg_match_all($numReg, $html, $numArray);
     empty($nameArray[0]) ? $username = null : ($username = substr($nameArray[0][0], 14, -37));
     empty($numArray[0]) ? $bookNum = null : ($bookNum = substr($numArray[0][0], 45, -25));
     $bookData['sdutnum'] = $sdutnum;
     /* after changed session*/
     $bookData['isLogin'] = $isLogin;
     $bookData['bookArray'] = $bookArray;
     $bookData['buttonArray'] = $buttonArray;
     $bookData['username'] = $username;
     $bookData['numArray'] = $numArray;
     $bookData['bookNum'] = $bookNum;
     return $bookData;
 }
开发者ID:Youthink,项目名称:Youthol-Wechat,代码行数:35,代码来源:Lib.php


示例4: PMA_sanitize

/**
 * Sanitizes $message, taking into account our special codes
 * for formatting.
 *
 * If you want to include result in element attribute, you should escape it.
 *
 * Examples:
 *
 * <p><?php echo PMA_sanitize($foo); ?></p>
 *
 * <a title="<?php echo PMA_sanitize($foo, true); ?>">bar</a>
 *
 * @uses    preg_replace()
 * @uses    strtr()
 * @param   string   the message
 * @param   boolean  whether to escape html in result
 *
 * @return  string   the sanitized message
 *
 * @access  public
 */
function PMA_sanitize($message, $escape = false, $safe = false)
{
    if (!$safe) {
        $message = strtr($message, array('<' => '&lt;', '>' => '&gt;'));
    }
    $replace_pairs = array('[i]' => '<em>', '[/i]' => '</em>', '[em]' => '<em>', '[/em]' => '</em>', '[b]' => '<strong>', '[/b]' => '</strong>', '[strong]' => '<strong>', '[/strong]' => '</strong>', '[tt]' => '<code>', '[/tt]' => '</code>', '[code]' => '<code>', '[/code]' => '</code>', '[kbd]' => '<kbd>', '[/kbd]' => '</kbd>', '[br]' => '<br />', '[/a]' => '</a>', '[sup]' => '<sup>', '[/sup]' => '</sup>');
    $message = strtr($message, $replace_pairs);
    $pattern = '/\\[a@([^"@]*)@([^]"]*)\\]/';
    if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER)) {
        $valid_links = array('http', './Do', './ur');
        foreach ($founds as $found) {
            // only http... and ./Do... allowed
            if (!in_array(substr($found[1], 0, 4), $valid_links)) {
                return $message;
            }
            // a-z and _ allowed in target
            if (!empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
                return $message;
            }
        }
        if (substr($found[1], 0, 4) == 'http') {
            $message = preg_replace($pattern, '<a href="' . PMA_linkURL($found[1]) . '" target="\\2">', $message);
        } else {
            $message = preg_replace($pattern, '<a href="\\1" target="\\2">', $message);
        }
    }
    if ($escape) {
        $message = htmlspecialchars($message);
    }
    return $message;
}
开发者ID:dingdong2310,项目名称:g5_theme,代码行数:52,代码来源:sanitizing.lib.php


示例5: loadColumnData

 protected function loadColumnData($table, $schema)
 {
     if (isset($this->data['columns'][$schema][$table])) {
         return;
     }
     $this->prepareDataHierarchy('columns', $schema, $table);
     $p = $this->adapter->getPlatform();
     $isColumns = array(array('C', 'ORDINAL_POSITION'), array('C', 'COLUMN_DEFAULT'), array('C', 'IS_NULLABLE'), array('C', 'DATA_TYPE'), array('C', 'CHARACTER_MAXIMUM_LENGTH'), array('C', 'CHARACTER_OCTET_LENGTH'), array('C', 'NUMERIC_PRECISION'), array('C', 'NUMERIC_SCALE'), array('C', 'COLUMN_NAME'), array('C', 'COLUMN_TYPE'));
     array_walk($isColumns, function (&$c) use($p) {
         $c = $p->quoteIdentifierChain($c);
     });
     $sql = 'SELECT ' . implode(', ', $isColumns) . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T' . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'COLUMNS')) . 'C' . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) . '  = ' . $p->quoteIdentifierChain(array('C', 'TABLE_SCHEMA')) . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) . '  = ' . $p->quoteIdentifierChain(array('C', 'TABLE_NAME')) . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) . ' IN (\'BASE TABLE\', \'VIEW\')' . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) . '  = ' . $p->quoteTrustedValue($table);
     if ($schema != self::DEFAULT_SCHEMA) {
         $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) . ' = ' . $p->quoteTrustedValue($schema);
     } else {
         $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) . ' != \'INFORMATION_SCHEMA\'';
     }
     $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
     $columns = array();
     foreach ($results->toArray() as $row) {
         $erratas = array();
         $matches = array();
         if (preg_match('/^(?:enum|set)\\((.+)\\)$/i', $row['COLUMN_TYPE'], $matches)) {
             $permittedValues = $matches[1];
             if (preg_match_all("/\\s*'((?:[^']++|'')*+)'\\s*(?:,|\$)/", $permittedValues, $matches, PREG_PATTERN_ORDER)) {
                 $permittedValues = str_replace("''", "'", $matches[1]);
             } else {
                 $permittedValues = array($permittedValues);
             }
             $erratas['permitted_values'] = $permittedValues;
         }
         $columns[$row['COLUMN_NAME']] = array('ordinal_position' => $row['ORDINAL_POSITION'], 'column_default' => $row['COLUMN_DEFAULT'], 'is_nullable' => 'YES' == $row['IS_NULLABLE'], 'data_type' => $row['DATA_TYPE'], 'character_maximum_length' => $row['CHARACTER_MAXIMUM_LENGTH'], 'character_octet_length' => $row['CHARACTER_OCTET_LENGTH'], 'numeric_precision' => $row['NUMERIC_PRECISION'], 'numeric_scale' => $row['NUMERIC_SCALE'], 'numeric_unsigned' => false !== strpos($row['COLUMN_TYPE'], 'unsigned'), 'erratas' => $erratas);
     }
     $this->data['columns'][$schema][$table] = $columns;
 }
开发者ID:jjs180,项目名称:dance-america,代码行数:35,代码来源:MysqlMetadata.php


示例6: get_dependencies

 private function get_dependencies()
 {
     preg_match_all('/#dependency (.*)/', $this->output, $dependencies);
     foreach ($dependencies[1] as $dependency) {
         $this->dependencies[] = trim($dependency);
     }
 }
开发者ID:holsinger,项目名称:openfloor,代码行数:7,代码来源:Dependencies.php


示例7: filtre_picture

/**
 * On modifie les URLS des images dans le corps de l'article
 */
function filtre_picture($content, $url, $id)
{
    $matches = array();
    $processing_pictures = array();
    // list of processing image to avoid processing the same pictures twice
    preg_match_all('#<\\s*(img)[^>]+src="([^"]*)"[^>]*>#Si', $content, $matches, PREG_SET_ORDER);
    foreach ($matches as $i => $link) {
        $link[1] = trim($link[1]);
        if (!preg_match('#^(([a-z]+://)|(\\#))#', $link[1])) {
            $absolute_path = get_absolute_link($link[2], $url);
            $filename = basename(parse_url($absolute_path, PHP_URL_PATH));
            $directory = create_assets_directory($id);
            $fullpath = $directory . '/' . $filename;
            if (in_array($absolute_path, $processing_pictures) === true) {
                // replace picture's URL only if processing is OK : already processing -> go to next picture
                continue;
            }
            if (download_pictures($absolute_path, $fullpath) === true) {
                $content = str_replace($matches[$i][2], $fullpath, $content);
            }
            $processing_pictures[] = $absolute_path;
        }
    }
    return $content;
}
开发者ID:akoenig,项目名称:wallabag,代码行数:28,代码来源:pochePictures.php


示例8: index

 function index()
 {
     $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS;
     $files = \GCore\Libs\Folder::getFiles($path, true);
     $strings = array();
     //function to prepare strings
     $prepare = function ($str) {
         /*$path = \GCore\C::get('GCORE_FRONT_PATH');
         		if(strpos($str, $path) !== false AND strpos($str, $path) == 0){
         			return '//'.str_replace($path, '', $str);
         		}*/
         $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : '';
         return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";';
     };
     foreach ($files as $file) {
         if (substr($file, -4, 4) == '.php') {
             // AND strpos($file, DS.'extensions'.DS) === TRUE){
             //$strings[] = $file;
             $file_code = file_get_contents($file);
             preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs);
             if (!empty($langs[2])) {
                 $strings = array_merge($strings, $langs[2]);
             }
         }
     }
     $strings = array_unique($strings);
     $strings = array_map($prepare, $strings);
     echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>';
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:29,代码来源:langs.php


示例9: Download

 public function Download($link)
 {
     global $premium_acc;
     // check link
     if (preg_match('@http:\\/\\/filejungle\\.com\\/l\\/[^|\\r|\\n]+@i', $link, $dir)) {
         if (!$dir[0]) {
             html_error('Filejungle folder link can\'t be found!');
         }
         $check = $this->GetPage($link);
         preg_match_all('@http:\\/\\/www\\.filejungle\\.com\\/f\\/[^"]+@i', $check, $fj, PREG_SET_ORDER);
         $arr_link = array();
         foreach ($fj as $match) {
             $arr_link[] = $match[0];
         }
         if (!$arr_link) {
             html_error('Can\'t find filejungle single link, probably folder is empty?');
         }
         $this->moveToAutoDownloader($arr_link);
     }
     if ($_REQUEST['premium_acc'] == 'on' && $_REQUEST['premium_user'] && $_REQUEST['premium_pass'] || $_REQUEST['premium_acc'] == 'on' && $premium_acc['filejungle_com']['user'] && $premium_acc['filejungle_com']['pass']) {
         return $this->Premium($link);
     } else {
         return $this->Free($link);
     }
 }
开发者ID:sayedharounokpay,项目名称:LikesPlanet,代码行数:25,代码来源:filejungle_com.php


示例10: getMaxColumns

 /**
  * Counting terminal char width
  * @return int
  */
 private static function getMaxColumns()
 {
     if (preg_match_all("/columns.([0-9]+);/", strtolower(@exec('stty -a | grep columns')), $output) && 2 == sizeof($output)) {
         return $output[1][0];
     }
     return 80;
 }
开发者ID:ansendu,项目名称:ansio,代码行数:11,代码来源:Terminal.php


示例11: createRow

 protected function createRow($items, $aData = array(), $level = 1)
 {
     if ($items->count()) {
         foreach ($items as $itm) {
             $getter = 'get' . $this->getValueField();
             $aResultTmp = array('Value' => call_user_func(array($itm, $getter)), 'Name' => $this->getTextFormat());
             $aRs = array();
             if (preg_match_all("/:(.*):/iU", $aResultTmp['Name'], $aRs)) {
                 foreach ($aRs[1] as $k => $val) {
                     $value = $itm;
                     if (strpos($val, "-") !== false) {
                         $xVal = explode("-", $val);
                         foreach ($xVal as $_val) {
                             $sGetter = 'get' . $_val;
                             $value = call_user_func(array($value, $sGetter));
                         }
                     } else {
                         $sGetter = 'get' . $val;
                         $value = call_user_func(array($value, $sGetter));
                     }
                     $aResultTmp['Name'] = str_replace($aRs[0][$k], $value, $aResultTmp['Name']);
                 }
             }
             if ($this->getIsTree() && $level > 1) {
                 $aResultTmp['Name'] = str_repeat(" |-- ", $level - 1) . $aResultTmp['Name'];
             }
             $aData[] = $aResultTmp;
             if ($itm->hasChilds()) {
                 $aData = $this->createRow($itm->getChilds(), $aData, $level + 1);
             }
         }
     }
     return $aData;
 }
开发者ID:ruxon,项目名称:module-ruxon,代码行数:34,代码来源:RuxonFormViewListColumn.class.php


示例12: extractPage

 public function extractPage($pageID, $pageTitle, $pageSource)
 {
     $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID());
     $category = Util::getMediaWikiNamespace($this->language, MW_CATEGORY_NAMESPACE);
     if (preg_match_all("/" . $category . ":(.*)/", $pageID, $match)) {
         $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_PREFLABEL, false), RDFtriple::Literal($this->decode_title($pageTitle), NULL, $this->language));
         $result->addTriple($this->getPageURI(), RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(SKOS_CONCEPT, false));
         if (preg_match_all("/\\[\\[" . $category . ":(.*)\\]\\]/", $pageSource, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $match) {
                 // split on | sign
                 if (strpos($match[1], '|') === false) {
                     $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($match[1]);
                 } else {
                     $split = explode('|', $match[1]);
                     $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($split[0]);
                 }
                 try {
                     $object = RDFtriple::URI($object);
                 } catch (Exception $e) {
                     echo 'Caught exception: ', $e->getMessage(), "\n";
                     continue;
                 }
                 $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_BROADER, false), $object);
             }
         }
     }
     return $result;
 }
开发者ID:ljarray,项目名称:dbpedia,代码行数:28,代码来源:SkosCategoriesExtractor.php


示例13: parseParameters

 private static function parseParameters($text)
 {
     $text = preg_replace('/[\\x{00a0}\\x{200b}]+/u', ' ', $text);
     if (!preg_match_all(static::$argumentsRegex, $text, $matches, PREG_SET_ORDER)) {
         return ltrim($text) ? array(ltrim($text) => null) : array();
     }
     $parameters = array();
     foreach ($matches as $match) {
         if (!empty($match[1])) {
             $parameters[strtolower($match[1])] = stripcslashes($match[2]);
         } elseif (!empty($match[3])) {
             $parameters[strtolower($match[3])] = stripcslashes($match[4]);
         } elseif (!empty($match[5])) {
             $parameters[strtolower($match[5])] = stripcslashes($match[6]);
         } elseif (isset($match[7]) && strlen($match[7])) {
             $parameters[stripcslashes($match[7])] = null;
         } elseif (isset($match[8])) {
             $parameters[stripcslashes($match[8])] = null;
         }
     }
     foreach ($parameters as $key => $value) {
         if (false !== strpos($value, '<') && 1 !== preg_match('/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value)) {
             $parameters[$key] = '';
         }
     }
     return $parameters;
 }
开发者ID:getgrav,项目名称:grav-plugin-shortcode-core,代码行数:27,代码来源:WordpressParser.php


示例14: get_recipe

function get_recipe($recipe)
{
    global $doc, $xpath;
    $url = 'http://www.marmiton.org/recettes/recherche.aspx?aqt=' . urlencode($recipe);
    $pageList = file_get_contents($url);
    // get response list and match recipes titles
    if (preg_match_all('#m_titre_resultat[^\\<]*<a .*title="(.+)".* href="(.+)"#isU', $pageList, $matchesList)) {
        // echo"<xmp>";print_r($matchesList[1]);echo"</xmp>";
        // for each recipes titles
        // foreach($matchesList[1] as $recipeTitle) {
        // }
        // take first recipe
        $n = 0;
        $url = 'http://www.marmiton.org' . $matchesList[2][$n];
        $pageRecipe = file_get_contents($url);
        // get recipe (minimize/clean before dom load)
        if (preg_match('#<div class="m_content_recette_main">.*<div id="recipePrevNext2"></div>\\s*</div>#isU', $pageRecipe, $match)) {
            $recipe = $match[0];
            $recipe = preg_replace('#<script .*</script>#isU', '', $recipe);
            $doc = loadDOC($pageRecipe);
            $xpath = new DOMXpath($doc);
            $recipeTitle = fetchOne('//h1[@class="m_title"]');
            $recipeMain = fetchOne('//div[@class="m_content_recette_main"]');
            return '<div class="recipe_root">' . $recipeTitle . $recipeMain . '</div>';
        }
    }
}
开发者ID:Broutard,项目名称:MagicMirror,代码行数:27,代码来源:recipe.php


示例15: smarty_outputfilter_trimwhitespace

/**
 * Smarty trimwhitespace outputfilter plugin
 *
 * File:     outputfilter.trimwhitespace.php<br>
 * Type:     outputfilter<br>
 * Name:     trimwhitespace<br>
 * Date:     Jan 25, 2003<br>
 * Purpose:  trim leading white space and blank lines from
 *           template source after it gets interpreted, cleaning
 *           up code and saving bandwidth. Does not affect
 *           <<PRE>></PRE> and <SCRIPT></SCRIPT> blocks.<br>
 * Install:  Drop into the plugin directory, call
 *           <code>$smarty->load_filter('output','trimwhitespace');</code>
 *           from application.
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @author Contributions from Lars Noschinski <[email protected]>
 * @version  1.3
 * @param string $source input string
 * @param object &$smarty Smarty object
 * @return string filtered output
 */
function smarty_outputfilter_trimwhitespace($source, $smarty)
{
    // Pull out the script blocks
    preg_match_all("!<script[^>]*?>.*?</script>!is", $source, $match);
    $_script_blocks = $match[0];
    $source = preg_replace("!<script[^>]*?>.*?</script>!is", '@@@SMARTY:TRIM:SCRIPT@@@', $source);
    // Pull out the pre blocks
    preg_match_all("!<pre[^>]*?>.*?</pre>!is", $source, $match);
    $_pre_blocks = $match[0];
    $source = preg_replace("!<pre[^>]*?>.*?</pre>!is", '@@@SMARTY:TRIM:PRE@@@', $source);
    // Pull out the textarea blocks
    preg_match_all("!<textarea[^>]*?>.*?</textarea>!is", $source, $match);
    $_textarea_blocks = $match[0];
    $source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is", '@@@SMARTY:TRIM:TEXTAREA@@@', $source);
    // remove all leading spaces, tabs and carriage returns NOT
    // preceeded by a php close tag.
    $source = trim(preg_replace('/((?<!\\?>)\\n)[\\s]+/m', '\\1', $source));
    // replace textarea blocks
    smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@", $_textarea_blocks, $source);
    // replace pre blocks
    smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@", $_pre_blocks, $source);
    // replace script blocks
    smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@", $_script_blocks, $source);
    return $source;
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:46,代码来源:outputfilter.trimwhitespace.php


示例16: Scaffold_image_replace_matrix

function Scaffold_image_replace_matrix($params)
{
    if (preg_match_all('/\\([^)]*?,[^)]*?\\)/', $params, $matches)) {
        foreach ($matches as $key => $original) {
            $new = str_replace(',', '#COMMA#', $original);
            $params = str_replace($original, $new, $params);
        }
    }
    $params = explode(',', $params);
    foreach (array('url', 'width', 'height', 'x', 'y') as $key => $name) {
        ${$name} = trim(str_replace('#COMMA#', ',', array_shift($params)));
    }
    $url = preg_replace('/\\s+/', '', $url);
    $url = preg_replace('/url\\([\'\\"]?|[\'\\"]?\\)$/', '', $url);
    if (!$x) {
        $x = 0;
    }
    if (!$y) {
        $y = 0;
    }
    $path = Scaffold::find_file($url);
    if ($path === false) {
        return false;
    }
    // Make sure theres a value so it doesn't break the css
    if (!$width && !$height) {
        $width = $height = 0;
    }
    // Build the selector
    $properties = "background:url(" . Scaffold::url_path($path) . ") no-repeat {$x}px {$y}px;\n\t\theight:{$height}px;\n\t\twidth:{$width}px;\n\t\tdisplay:block;\n\t\ttext-indent:-9999px;\n\t\toverflow:hidden;";
    return $properties;
}
开发者ID:behaba,项目名称:csscaffold,代码行数:32,代码来源:image-replace-matrix.php


示例17: tc_generate_default_options

 /**
  *
  * @package FPU
  * @since FPU 1.4.3
  */
 function tc_generate_default_options($map, $option_group = null)
 {
     $defaults = array();
     //do we have to look in a specific group of option (plugin?)
     $option_group = is_null($option_group) ? TC_wfc::$instance->plug_option_prefix : $option_group;
     foreach ($map['add_setting_control'] as $key => $options) {
         //check it is a customizr option
         if (false !== strpos($key, $option_group)) {
             //isolate the option name between brackets [ ]
             $option_name = '';
             $option = preg_match_all('/\\[(.*?)\\]/', $key, $match);
             if (isset($match[1][0])) {
                 $option_name = $match[1][0];
             }
             //write default option in array
             if (isset($options['default'])) {
                 $defaults[$option_name] = $options['default'];
             } else {
                 $defaults[$option_name] = null;
             }
         }
         //end if
     }
     //end foreach
     return $defaults;
 }
开发者ID:umairriaz90,项目名称:Daschug1,代码行数:31,代码来源:class_utils_wfc.php


示例18: find_variables

 public function find_variables($json)
 {
     global $__rgt_replace_set;
     $__rgt_replace_set = array();
     preg_match_all('/__(.*?)\\[([^\\]]+)\\]__/', $json, $mall);
     $sid_set = array();
     for ($i = 0; $i < count($mall[0]); $i++) {
         $sid++;
         if (!isset($__rgt_replace_set[$mall[1][$i]])) {
             $__rgt_replace_set[$mall[1][$i]] = $sid;
         }
         if ($mall[2][$i] == "SID" && !isset($sid_set[$mall[1][$i]])) {
             $sid_set[$mall[1][$i]] = $sid;
         }
         if ($mall[2][$i] == "TEXT" && !isset($text_set[$mall[1][$i]])) {
             $variable_set[$mall[1][$i]] = array('TEXT' => array());
         }
     }
     $json = preg_replace_callback('/__(.*?)\\[[^\\]]+\\]__/', "__r_r", $json);
     $d = json_decode($json, true);
     foreach ($sid_set as $sidname => $sid) {
         foreach ($d['datapoints'] as $dp) {
             if ($dp['sid'] == $sid) {
                 $variable_set[$sidname]['SID'][] = array($dp['metric_name'], $dp['metric_type']);
             }
         }
     }
     return $variable_set;
 }
开发者ID:rphillips,项目名称:reconnoiter,代码行数:29,代码来源:Reconnoiter_GraphTemplate.php


示例19: snakeCase

 public static function snakeCase($string)
 {
     preg_match_all("/(^[a-z_][a-z0-9_]*|[A-Z]+(?![a-z])|[A-Z][a-z0-9_]+)/", $string, $matches);
     return join("_", array_map(function ($e) {
         return mb_strtolower($e);
     }, $matches[1]));
 }
开发者ID:yurykabanov,项目名称:xsd2blade,代码行数:7,代码来源:Helpers.php


示例20: findTranslations

 public function findTranslations($path = null)
 {
     $path = $path ?: base_path();
     $keys = array();
     $functions = array('trans', 'trans_choice', 'Lang::get', 'Lang::choice', 'Lang::trans', 'Lang::transChoice', '@lang', '@choice');
     $pattern = "(" . implode('|', $functions) . ")" . "\\(" . "[\\'\"]" . "(" . "[a-zA-Z0-9_-]+" . "([.][^)]+)+" . ")" . "[\\'\"]" . "[\\),]";
     // Close parentheses or new parameter
     // Find all PHP + Twig files in the app folder, except for storage
     $finder = new Finder();
     $finder->in($path)->exclude('storage')->name('*.php')->name('*.twig')->files();
     /** @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($finder as $file) {
         // Search the current file for the pattern
         if (preg_match_all("/{$pattern}/siU", $file->getContents(), $matches)) {
             // Get all matches
             foreach ($matches[2] as $key) {
                 $keys[] = $key;
             }
         }
     }
     // Remove duplicates
     $keys = array_unique($keys);
     // Add the translations to the database, if not existing.
     foreach ($keys as $key) {
         // Split the group and item
         list($group, $item) = explode('.', $key, 2);
         $this->missingKey('', $group, $item);
     }
     // Return the number of found translations
     return count($keys);
 }
开发者ID:txandy,项目名称:laravel-translation-manager,代码行数:31,代码来源:Manager.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP preg_quote函数代码示例发布时间:2022-05-15
下一篇:
PHP preg_match函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap