亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP uses regular expressions to write a UBB text editor

Let’s take a look at the UBB editor. This is a text processing technology often used on websites. Because I use the UBB file editor, the format I specified can exist. Users cannot display the format that I do not specify on the website.

Let’s take a look at the effect:

<?php
$string='[b]為你寫(xiě)詩(shī)[/b]
[i]為你做不可能事[/i]
[u]哎呀,哥不是寫(xiě)情詩(shī)[/u]
[color=Red]哥是在說(shuō)歌詞[/color]
[size=7]吳克群[/size]
[qq]123123123[/qq]';

//匹配UBB字符
$pattern=array(
    '/\[b\](.*)\[\/b\]/i',
    '/\[i\](.*)\[\/i\]/iU',
    '/\[u\](.*?)\[\/u\]/i',
    '/\[color=(.*?)\](.*?)\[\/color\]/',
    '/\[size=(\d)\](.*?)\[\/size\]/',
    '/\[qq\](\d{5,12})\[\/qq\]/',

    );

//需要替換的UBB字符
$replace=array(
    '<b>\1</b><br />',
    '<i>\1</i><br />',
    '<u>\1</u><br />',
    '<font color="\1">\2</font><br />',
    '<font size="\1">\2</font><br />',
    '<a href="http://wpa.qq.com/msgrd?V=1&Uin=\1&amp;Site=[Discuz!]&amp;Menu=yes"
 target="_blank"><img src="http://wpa.qq.com/pa?p=1:\1:1" border="0"></a>',
    );

//使用正則匹配$string,將$string當(dāng)中的值變?yōu)?replace的效果
$ubb=preg_replace($pattern,$replace,$string);

echo $ubb;
?>

The implementation is more advanced. You can let the user pass the result in the form and let the user pass the value.

You convert the output to UBB format.

In the next chapter, we learn about the file system, and then we will explain to you something more interesting: the web page collector.


Continuing Learning
||
<?php $string='[b]為你寫(xiě)詩(shī)[/b] [i]為你做不可能事[/i] [u]哎呀,哥不是寫(xiě)情詩(shī)[/u] [color=Red]哥是在說(shuō)歌詞[/color] [size=7]吳克群[/size] [qq]123123123[/qq]'; //匹配UBB字符 $pattern=array( '/\[b\](.*)\[\/b\]/i', '/\[i\](.*)\[\/i\]/iU', '/\[u\](.*?)\[\/u\]/i', '/\[color=(.*?)\](.*?)\[\/color\]/', '/\[size=(\d)\](.*?)\[\/size\]/', '/\[qq\](\d{5,12})\[\/qq\]/', ); //需要替換的UBB字符 $replace=array( '<b>\\1</b><br />', '<i>\\1</i><br />', '<u>\\1</u><br />', '<font color="\\1">\\2</font><br />', '<font size="\\1">\\2</font><br />', '<a href="http://wpa.qq.com/msgrd?V=1&Uin=\\1&Site=[Discuz!]&Menu=yes" target="_blank"><img src="http://wpa.qq.com/pa?p=1:\\1:1" border="0"></a>', ); //使用正則匹配$string,將$string當(dāng)中的值變?yōu)?replace的效果 $ubb=preg_replace($pattern,$replace,$string); echo $ubb; ?>
submitReset Code