Stuck_out_tongue_winking_eye a ubbcode function, very fast.

Source: Internet
Author: User
I saw someone publish in front
But it's slow and it's very long.
This gives a
function Ubb ($STR) {
$color =array (' Red ', ' blue ', ' green ');
$str =eregi_replace (' \[url\] ([a-za-z0-9@:%_.~#-\?&]+) \[\/url\] ', ' \\1 ', $str);//url
$str =eregi_replace (' \[url=http://([a-za-z0-9@:%_.~#-\?&]+) \] (. +) \[\/url\] ', ' \\2 ', $str);
$str =eregi_replace (' \[url= ([a-za-z0-9@:%_.~#-\?&]+) \] (. +) \[\/url\] ', ' \\2 ', $str);
$str =eregi_replace (' \[img\] ([a-za-z0-9@:%_.~#-\?&]+) \[\/img\] ', ' \\1 ', $str);//img
$str =eregi_replace (' \[h ([1-6]) \] (. +) \[\/h[1-6]\] ', ' \\2 ', $str);//h1-6
$str =eregi_replace (' \[email\] ([_\.0-9a-z-]+@ ([0-9a-z][0-9a-z-]+\.)] +[a-z]{2,3}) \[\/email\] ', ' \\1 ', $str);//email
$str =eregi_replace (' \[email= ([_\.0-9a-z-]+@ ([0-9a-z][0-9a-z-]+\.)] +[a-z]{2,3}) \] (. +) \[\/email\] ', ' \\2 ', $str);
$str =eregi_replace (' \[b\] (. +) \[\/b\] ', ' \\1', $STR);
$str =eregi_replace (' \[i\] (. +) \[\/i\] ', ' \\1', $STR);
$str =eregi_replace (' \[size= (. +) \] (. +) \[\/size\] ', ' \\2 ', $str);
$str =eregi_replace (' \[color= (. +) \] (. +) \[\/color\] ', ' \\2 ', $str);
$str =eregi_replace (' \[sub\] (. +) \[\/sub\] ', ' \\1 ', $str);//Bottom mounted
$str =eregi_replace (' \[sup\] (. +) \[\/sup\] ', ' \\1 ', $str);//superscript
for ($i =0; $i <=count ($color), $i + +) $str =eregi_replace (' \['. $color [$i]. ' \] (. +) \[\/'. $color [$i]. ' \] ', ' \\1 ', $str);
$str =preg_replace ("/\[quote\" (. +?) \[\/quote\]/is ","
quote:\\1
", $STR);
$str =preg_replace ("/\[code\" (. +?) \[\/code\]/is ","
Code: \\1
", $STR);
$str =preg_replace ("/\[sig\" (. +?) \[\/sig\]/is ","

--------------------------
\\1
--------------------------", $STR);
return $str;
}

The above describes the Stuck_out_tongue_winking_eye a Ubbcode function, very fast, including the stuck_out_tongue_winking_eye aspect of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.