温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php正则替换

发布时间:2020-04-07 16:51:19 来源:网络 阅读:533 作者:jennefer 栏目:web开发

$string = 'April 15, 2003';
$pattern = '/(\w+) (\d+), (\d+)/i';
$replacement = '${1}1,\3';

//$replacement '${1}1,$3';

//$replacement '${1}1,{3}';

echo preg_replace($pattern, $replacement, $string);
echo '<br/>';
//-----------------------------


$string = 'The quick brown fox jumped over the lazy dog.';
$patterns = array();
$patterns[0] = '/quick/';
$patterns[1] = '/brown/';
$patterns[2] = '/fox/';
$replacements = array();
$replacements[2] = 'bear';
$replacements[1] = 'black';
$replacements[0] = 'slow';
echo preg_replace($patterns, $replacements, $string);

echo '<br/>';
//---------------------------------
    //$d = $db->select('select * from <{:task}> limit 2');
        self::$_sql = preg_replace('/<{:\s*(.*?)\s*}>/', $this->_prefix . '\1', $sql);
        $this->_res = mysql_query(self::$_sql, $this->_db);


//---------------------------------

    if (preg_match('/^p-(\d+)$/', $segment3, $m)) {
            $page = intval($m[1]);
        }
        else if (preg_match('/^\d+$/', $segment3)) {
            $task_type = intval($segment3);
            if (preg_match('/^p-(\d+)$/', $setment4, $m2)) {
                $page = intval($m2[1]);
            }    
        }

  preg_match_all("/{([^\}\{\n]*)}/e",$contents , $source);
  echo   preg_replace("/{([^\}\{\n]*)}/e", " ", $contents);

  return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);



$str = "http://112.125.116.137:9012/llys//lldoctor";               
            $pattern = '/(http:\/\/[^\/]+\/)(.*)/i';
             preg_match($pattern,$str,$result);  
            echo "aaaaaa" ; dump($result);
            preg_match("/php/i", "PHP is the web scripting language of choice.",$result);
            echo "bbbb" ; dump( $result);
             preg_match('/http:\/\/[^\/]+\//i', $str ,$result);
            echo "bbbb" ; dump( $result);
            exit;
           echo  $this->serinfo ."|". U('Home/Public/psysSendMessages');

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI