国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

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]為你寫詩(shī)[/b]
[i]為你做不可能事[/i]
[u]哎呀,哥不是寫情詩(shī)[/u]
[color=Red]哥是在說歌詞[/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]為你寫詩(shī)[/b] [i]為你做不可能事[/i] [u]哎呀,哥不是寫情詩(shī)[/u] [color=Red]哥是在說歌詞[/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