Skip to content

Instantly share code, notes, and snippets.

@ondrejmirtes
Created February 20, 2011 19:26
Show Gist options
  • Save ondrejmirtes/836229 to your computer and use it in GitHub Desktop.
Save ondrejmirtes/836229 to your computer and use it in GitHub Desktop.
<?php
echo preg_replace(array(
'~\[b\](\w+)\[/b\]~',
'~\[i\](\w+)\[/i\]~i',
'~\[u\](\w+)\[/u\]~i',
'~\[s\](\w+)\[/s\]~i',
'~\[img\](\w+)\[/img\]~i',
'~\[url=(\w+)\](\w+)\[/url\]~i',
'~\[email\](\w+)\[/email\]~i',
'~\[quote=(\w+)\](\w+)\[/quote\]~i',
), array(
'<strong>$1</strong>',
'<em>$1</em>',
'$1',
'<del>$1</del>',
'<img src="$1" alt="">',
'<a rel="nofollow" href="$1">$2</a>',
'<a href="mailto:$1">$1</a>',
'<blockquote><p><strong>$1</strong> napsal(a):</p><p>$2</p></blockquote>',
),
'[b]tučné[/b]
[i]kurzíva[/i]
[u]bývalé podtržené (nyní bez tagů)[/u]
[s]přeškrtnuté[/s]
[img]http://obrazek[/img]
[url=http://test]test[/url]
[email][email protected][/email]
[quote=Test]text[/quote]'
);
/* výsledek:
[b]tučné[/b]
[i]kurzíva[/i]
[u]bývalé podtržené (nyní bez tagů)[/u]
[s]přeškrtnuté[/s]
[img]http://obrazek[/img]
[url=http://test]test[/url]
[email][email protected][/email]
<blockquote><p><strong>Test</strong> napsal(a):</p><p>text</p></blockquote> */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment