佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > 自定義ubb代碼,preg_replace()函數(shù)的一些代碼

自定義ubb代碼,preg_replace()函數(shù)的一些代碼

熱門標(biāo)簽:阿里云 Linux服務(wù)器 銀行業(yè)務(wù) Mysql連接數(shù)設(shè)置 團(tuán)購網(wǎng)站 電子圍欄 科大訊飛語音識別系統(tǒng) 服務(wù)器配置
function ubb($Text) { 
  $Text=htmlspecialchars($Text); 
  $Text=ereg_replace("\r\n","br>",$Text); 
  $Text=ereg_replace("\r","br>",$Text); 
  $Text=nl2br($Text); 
  $Text=preg_replace("/\\t/is","  ",$Text); 
  $Text=preg_replace("/\[h1\](.+?)\[\/h1\]/is","h1>\\1/h1>",$Text); 
  $Text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","h2>\\1/h2>",$Text); 
  $Text=preg_replace("/\[h3\](.+?)\[\/h3\]/is","h3>\\1/h3>",$Text); 
  $Text=preg_replace("/\[h4\](.+?)\[\/h4\]/is","h4>\\1/h4>",$Text); 
  $Text=preg_replace("/\[h5\](.+?)\[\/h5\]/is","h5>\\1/h5>",$Text); 
  $Text=preg_replace("/\[h6\](.+?)\[\/h6\]/is","h6>\\1/h6>",$Text); 

  $Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","a href=\\1>\\1/a>",$Text); 
  $Text=preg_replace("/\[url\](.+?)\[\/url\]/is","a href=\"http://\\1\">http://\\1/a>",$Text); 
  $Text=preg_replace("/\[url=(http:\/\/.+?)\](.*)\[\/url\]/is","a href=\\1>\\2/a>",$Text); 
  $Text=preg_replace("/\[url=(.+?)\](.*)\[\/url\]/is","a href=http://\\1>\\2/a>",$Text); 

  $Text=preg_replace("/\[img\](.+?)\[\/img\]/is","img src=\\1>",$Text); 
  $Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","font color=\\1>\\2/font>",$Text); 
  $Text=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/is","font size=\\1>\\2/font>",$Text); 
  $Text=preg_replace("/\[sup\](.+?)\[\/sup\]/is","sup>\\1/sup>",$Text); 
  $Text=preg_replace("/\[sub\](.+?)\[\/sub\]/is","sub>\\1/sub>",$Text); 
  $Text=preg_replace("/\[pre\](.+?)\[\/pre\]/is","pre>\\1/pre>",$Text); 
  $Text=preg_replace("/\[email\](.+?)\[\/email\]/is","a href=\\1>\\1/a>",$Text); 
  $Text=preg_replace("/\[i\](.+?)\[\/i\]/is","i>\\1/i>",$Text); 
  $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","b>\\1/b>",$Text); 
  $Text=preg_replace("/\[quote\](.+?)\[\/quote\]/is","blockquote>font size='2' face='Courier New'>quote:/font>hr>\\1hr>/blockquote>", $Text); 
  $Text=preg_replace("/\[code\](.+?)\[\/code\]/is","blockquote>font size='2' face='Courier New'>code:/font>hr color='lightblue'>i>\\1/i>hr color='lightblue'>/blockquote>", $Text); 
  $Text=preg_replace("/\[sig\](.+?)\[\/sig\]/is","div style='text-align: left; color: darkgreen; margin-left: 5%'>br>br>--------------------------br>\\1br>--------------------------/div>", $Text); 
return $Text; 

function str($msg){
  global $admin;
  if(!$admin[html]) $msg=htmlspecialchars($msg);
  if($admin[ubb]) $msg=ubb($msg);
  $msg=nl2br($msg); #處理message
  $msg= str_replace("\n","",$msg); #處理message
  $msg= str_replace("\r","",$msg); #處理message
  return $msg;
}
function error($msg){
global $admin;
?>

中的
$Text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","h2>\\1/h2>",$Text); 

里面的 ("/\[h2](.+?)\[\/h2]/is","h2>\\1/h2>",$text)

/\[h2](.+?)\[\/h2]/is  轉(zhuǎn)化成 h2>\\1/h2>

/\[h2](.+?)\[\/h2]/is  里面的 這些"/\(.+?)\&;"之類的符號是怎么看的?是什么意思?
______________________________________________________________________________________________

\是轉(zhuǎn)意,\本身是特殊符號,如果要作為普通字符就要用\來轉(zhuǎn)意,就是說\\表示()也是特殊符號,所以要用\轉(zhuǎn)意
您可能感興趣的文章:
  • php正則之函數(shù) preg_replace()參數(shù)說明
  • eregi_replace()中特殊字符的處理方法
  • javascript replace()用法詳解附實(shí)例代碼
  • javascript replace()正則替換實(shí)現(xiàn)代碼
  • js replace() 文本替換你所不知的
  • js中字符替換函數(shù)String.replace()使用技巧
  • PHP preg_replace() 正則替換所有符合條件的字符串
  • 淺談jQuery中replace()方法
  • 淺談javascript中replace()方法
  • 淺談C++中replace()方法

標(biāo)簽:棗莊 廣元 衢州 蚌埠 衡水 江蘇 大理 萍鄉(xiāng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《自定義ubb代碼,preg_replace()函數(shù)的一些代碼》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    万州区| 雅江县| 齐河县| 海盐县| 龙井市| 衢州市| 宜兰市| 南康市| 英超| 尼勒克县| 涪陵区| 成安县| 南澳县| 宜宾市| 陈巴尔虎旗| 临夏市| 奈曼旗| 即墨市| 陆河县| 伊吾县| 新巴尔虎左旗| 嘉鱼县| 遂平县| 梅州市| 平度市| 金寨县| 调兵山市| 额尔古纳市| 西和县| 平舆县| 周宁县| 迁安市| 大新县| 杨浦区| 治县。| 东乌珠穆沁旗| 新津县| 柞水县| 新巴尔虎右旗| 炉霍县| 永吉县|