BB-Code

Convert a simple subset of BB-Code into HTML5

Instead of <u> (deprecated) use <span class=u>.

IN

[b]Hello World![/b]
[url=http://jagc.org/]JAGC[/url]
[img=http://jagc.org/images/logo_h.png]JAGC[/img]

OUT

<strong>Hello World!</strong>
<a href="http://jagc.org/">JAGC</a>
<img src="http://jagc.org/images/logo_h.png" alt="JAGC">

IN

[b]Bold[/b]
[i]Itallic[/i]
[u]Underlined[/u]

OUT

<strong>Bold</strong>
<em>Itallic</em>
<span class=u>Underlined</span>

IN

[url=http://en.wikipedia.org/wiki/Perl]Perl[/url]
[img=http://invalid.url/image.png]You dont see this imge[/img]

OUT

<a href="http://en.wikipedia.org/wiki/Perl">Perl</a>
<img src="http://invalid.url/image.png" alt="You dont see this imge">
Login to submit solution


99 symbols pyth
Sat Oct 29 20:47:36 2016 Sait2000
.v.ZCim-i%Vd[16K64K)KJ5816cCM"⃢蒳滢㪉퀴侐皕片酀꒥묓멦螶셣䄋Ḋ塐⃝쿋鏺䭚㨦ⶋ━욟閩ậꢚ섬嚺㔆촚圡☾虝㍐錁縁焯리⤯餟届滹轶釖慎슬ꕴ婶絻翌뜮ꌨ杧頠㲵澮쁰룏황䮞⾺緛"3*J9
101 symbols pyth
Sat Oct 29 19:56:30 2016 Sait2000
.v.ZCim-i%Vd[16=T64T)T=T5816cCM"⃢蒳滢㪉퀴侐皕片酀꒥묓멦螶셣䄋Ḋ塐⃝쿋鏺䭚㨦ⶋ━욟閩ậꢚ섬嚺㔆촚圡☾虝㍐錁縁焯리⤯餟届滹轶釖慎슬ꕴ婶絻翌뜮ꌨ杧頠㲵澮쁰룏황䮞⾺緛"3*T9
166 symbols pyth
Sat Oct 29 20:27:42 2016 Sait2000
:::::::jb.z"\["\<"b]""strong>""i]""em>""/u]""/span>""u]""span class=u>""url=(.*)](.*)</url]""a href=\"\\1\">\\2</a>""img=(.*)](.*)</img]""img src=\"\\1\" alt=\"\\2\">
167 symbols pyth
Sat Oct 29 19:50:09 2016 Sait2000
:::::::jb.z"\["\<"b]""strong>""i]""em>""/u]""/span>""u]""span class=u>""url=(.*)](.*)</url]""a href=\"\\1\">\\2</a>""img=(.*)](.*)</img]""img src=\"\\1\" alt=\"\\2\">"
168 symbols bash
Sun Aug 14 16:22:53 2016 hidefromkgb
b='>/;s/img=(.*)](.*)<\/img]/';sed -r "s/\[/</g;s/b]/strong>/g;s/i]/em>/g;s/\/u]/\/span>/;s/u]/span class=u${b//img/url}a href=\"\1\">\2<\/a$b"'img src="\1" alt="\2">/'
169 symbols bash
Sun Aug 14 16:07:11 2016 hidefromkgb
b='>/;s/url=(.*)](.*)<\/url]';sed -r "s/\[/</g;s/b]/strong>/g;s/i]/em>/g;s/\/u]/\/span>/;s/u]/span class=u$b/a href=\"\1\">\2<\/a${b//url/img}"'/img src="\1" alt="\2">/'
172 symbols bash
Sun Aug 14 16:05:54 2016 hidefromkgb
b='>/;s/url=([^]]*)](.*)<\/url]';sed -r "s/\[/</g;s/b]/strong>/g;s/i]/em>/g;s/\/u]/\/span>/;s/u]/span class=u$b/a href=\"\1\">\2<\/a${b//url/img}"'/img src="\1" alt="\2">/'
175 symbols perl
Sat Aug 13 23:17:51 2016 vakorol
#!/usr/bin/perl -p
%h=(b,strong,i,em,u,span,url,a,img,X);$p='=([^>]+)>([^<]+)';s|\[(/?)(\w+)|<$1$h{$2}|g;s|\]|>|g;s|a$p|a href="$1">$2|g;s|X$p</.+>|img src="$1" alt="$2">|g;s|<span|$& class=u|
178 symbols bash
Tue Jul 26 19:01:35 2016 hidefromkgb
b='=([^]]*)]([^<]*)<';sed -r "s/\[/</g;s/b]/strong>/g;s/i]/em>/g;s/\/u]/\/span>/;s/u]/span class=u>/;s/url$b\/url]/a href=\"\1\">\2<\/a>/;s/img$b\/img]"'/img src="\1" alt="\2">/'
181 symbols perl
Tue Jan 13 20:00:50 2015 vakorol
#!/usr/bin/perl -p
%h=(b,strong,i,em,u,span,url,a,img,img);$p='=([^>]+)>([^<]+)';s|\[(/?)(\w+)|<$1$h{$2}|g;s|\]|>|g;s|a$p|a href="$1">$2|g;s|img$p</.+>|img src="$1" alt="$2">|g;s|<span|$& class=u| 
183 symbols bash
Tue Jul 26 18:58:58 2016 hidefromkgb
b='=([^]]*)\]([^<]*)<';sed -r "s/\[/</g;s/b\]/strong>/g;s/i\]/em>/g;s/\/u\]/\/span>/;s/u\]/span class=u>/;s/url$b\/url]/a href=\"\1\">\2<\/a>/;s/img$b\/img]"'/img src="\1" alt="\2">/'
186 symbols bash
Tue Jul 26 18:56:16 2016 hidefromkgb
b='([^]]*)\]([^<]*)<';sed -r "s/\[/</g;s/b\]/strong>/g;s/i\]/em>/g;s/\/u\]/\/span>/;s/u\]/span class=u>/;s/url=$b\/url]/a href=\"\1\">\2<\/a>/;s/img=$b\/img]/img src=\"\1\" alt=\"\2\">/"
187 symbols perl
Mon Jan 12 00:30:06 2015 danieljabailey
#!/usr/bin/perl -p
$e=qr/([^\[\]=]+)/;%r=split/:/,'b:strong:i:em:url:a href:img:img src:u:span class=u';s|\[$e=?$e?\]$e.*|<$r{$1}@{[$2?"=\"$2\"":'']}>$3</@{[$r{$1}=~/([^ ]*)/]}>|;s:>([^<]+).+mg: alt="$1":
191 symbols perl
Mon Sep 29 16:07:10 2014 vakorol
#!/usr/bin/perl -p
%h=(b,strong,i,em,u,span,url,a,img,img);$p='([^\]]+)\]([^\[]+)';s/\[url=$p/<a href="$1">$2/g;s/\[img=$p/<img src="$1" alt="$2">/g;s|\[(/?)(\w+)\]|<$1$h{$2}>|g;s|</img>||;s|<span|$& class=u|
248 symbols perl
Fri Sep 26 00:27:30 2014 gabrielmad
#!/usr/bin/perl -p
%h=(i,em,b,strong);s,\[([ib])\](.+?)\[/\1\],<$h{$1}>$2</$h{$1}>,g;s,\[url=(.*?)\],<a href="\1">,;s,\[/url\],</a>,;s,\[u\],<span class=u>,;s,\[/u\],</span>,;s,\[img\](.+)\[/img\],<img src="\1">,;s,\[img=(.+)\](.+)\[/img\],<img src="\1" alt="\2">,;
249 symbols perl
Thu Sep 25 07:58:51 2014 gabrielmad
#!/usr/bin/perl -0p
%h=(i,em,b,strong);s,\[([ib])\](.+?)\[/\1\],<$h{$1}>$2</$h{$1}>,g;s,\[url=(.*?)\],<a href="\1">,;s,\[/url\],</a>,;s,\[u\],<span class=u>,;s,\[/u\],</span>,;s,\[img\](.+)\[/img\],<img src="\1">,;s,\[img=(.+)\](.+)\[/img\],<img src="\1" alt="\2">,;
275 symbols perl
Tue Sep 23 02:16:23 2014 maxymania
while(<>){
s,\[url=(.*?)\],<a href="\1">,;
s,\[/url\],</a>,;
s,\[b\],<strong>,;s,\[/b\],</strong>,;
s,\[i\],<em>,;s,\[/i\],</em>,;
s,\[u\],<span class=u>,;s,\[/u\],</span>,;
s,\[img\](.*?)\[/img\],<img src="\1">,;
s,\[img=(.*?)\](.*?)\[/img\],<img src="\1" alt="\2">,;
print}
351 symbols haskell
Mon Mar 16 06:00:11 2015 YoshikuniJujo
main=interact$unlines.map(w.b).lines
(#)=(++)
b(_:s)=(g,v,takeWhile(/='[')r)where(t,_:r)=span(/=']')s;(g,v)=case span(/='=')t of(g,_:v)->(g,v);_->(t,"")
w("b","",x)="<strong>"#x#"</strong>"
w("i","",x)="<em>"#x#"</em>"
w("u","",x)="<span class=u>"#x#"</span>"
w("url",u,x)="<a href=\""#u#"\">"#x#"</a>"
w("img",u,x)="<img src=\""#u#"\" alt=\""#x#"\">"
365 symbols python3
Fri Feb 27 06:27:42 2015 bluebear94
from re import*
import sys
for l in sys.stdin:
  print(sub("\[img=([^]]*)\]([^\[]*)\[/img\]",'<img src="\\1" alt="\\2">',sub("\[url=([^]]*)\]",'<a href="\\1">',l.replace('[b]','<strong>').replace('[/b]','</strong>').replace('[i]','<em>').replace('[/i]','</em>').replace('[u]','<span class=u>').replace('[/u]','</span>').replace('[/url]','</a>').replace('\n',''))))

View all solutions