Hey
Werkt allemaal heel fijn. Maar nu wil ik als je een quote in een quote hebt dat de quote wordt veranderd in [..].
Omdat ik veel te weinig ervaring heb met Regex, ik heb geluk dat ik dit kon vinden op Wmcity vraag ik het aan jullie. Ik heb gegoogled. Maar dan krijg je allemaal uitleg over Invision Power board enz.
Groetjes
Koen
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| function validate($text) { $text = htmlspecialchars($text); $text = nl2br($text); $text = preg_replace( '/\[b\](.+?)\[\/b\]/is', '<b>\\1</b>', $text ); $text = preg_replace( '/\[i\](.+?)\[\/i\]/is', '<i>\\1</i>', $text ); $text = preg_replace( '/\[u\](.+?)\[\/u\]/is', '<u>\\1</u>', $text ); $text = preg_replace( '/\[center\](.+?)\[\/center\]/is', '<center>\\1</center>', $text ); $text = preg_replace( '/\[color=(.+?)\](.+?)\[\/color\]/is', '<span style="color: \\1;">\\2</span>', $text ); $text = preg_replace( '/\[url=(.+?)\](.+?)\[\/url\]/is', '<a href="\\1">\\2</a>', $text ); $text = preg_replace( '/\[url\](.+?)\[\/url\]/is', '<a href="\\1">\\1</a>', $text ); $text = preg_replace( '/\[img\](.+?)\[\/img\]/is', '<img src="\\1" />', $text ); $text = preg_replace( '/\[quote\](.+?)\[\/quote\]/is', '<blockquote><strong>Citaat:</strong><br />\\1</blockquote>', $text ); $text = preg_replace( '/\[quote=(.+?)\](.+?)\[\/quote\]/is', '<blockquote><strong>Citaat van \\1:</strong><br />\\2</blockquote>', $text ); $text = preg_replace( '/\[offtopic\](.+?)\[\/offtopic\]/is', '<span style="font-size: 10px; color: gray;"><em>Offtopic:<br />\\1</em></span>', $text ); $text = preg_replace( '/\[off\](.+?)\[\/off\]/is', '<span style="font-size: 10px; color: gray;"><em>Offtopic:<br />\\1</em></span>', $text ); return $text; } |
Werkt allemaal heel fijn. Maar nu wil ik als je een quote in een quote hebt dat de quote wordt veranderd in [..].
Omdat ik veel te weinig ervaring heb met Regex, ik heb geluk dat ik dit kon vinden op Wmcity vraag ik het aan jullie. Ik heb gegoogled. Maar dan krijg je allemaal uitleg over Invision Power board enz.
Groetjes
Koen