All pastes #729797 Raw Edit

Unnamed

public php v1 · immutable
·published 2007-10-08 10:39 UTC
rendered paste body
	function parse($text) {		$text = preg_replace('/\[url=(.+?)\](.+?)\[\/url\]/i', '<a href="${1}">${2}</a>', $text); // [URL=http://mysite.com]check out my site[/URL]		$text = preg_replace('/\[b\](.+?)\[\/b\]/i', '<b>${1}</b>', $text); // [b] this text is bold[/b]		$text = preg_replace('/\[u\](.+?)\[\/u\]/i', '<u>${1}</u>', $text); // [u] this text is underlined[/u]		$text = preg_replace('/\[i\](.+?)\[\/i\]/i', '<i>${1}</i>', $text); // [i] italic text[/i]		$text = preg_replace('/\[img=(.+?)\]/i', '<img src="${1}">', $text); // [img=http://www.image.url]		$text = preg_replace('/\[right\](.+?)\[\/right\]/i', '<p align="right">${1}</p>', $text); // [right] text to be aligned to the right[/right]		$text = preg_replace('/\[left\](.+?)\[\/left\]/i', '<p align="left">${1}</p>', $text); // [left] text to be aligned to the left[/elft]		$text = preg_replace('/\[center\](.+?)\[\/center\]/i', '<center>${1}</center>', $text); // [center] text to be centred on the page[/center]		$text = preg_replace('/\[color=(.+?)\](.+?)\[\/color\]/i', '<font color="${1}">${2}</font>', $text); // [color=(red|white|blue|etc)] color this text[/color]		$text = preg_replace('/\[size=([1-5])\](.+?)\[\/size\]/i', '<h${1}>${2}</h>', $text); // [size=(1-5)] change the size of the text based on the <h> tag, 1 being largest, 5 being smallest[/size]		$text = preg_replace('/\[font=(.+?)\](.+?)\[\/font\]/i', '<font face="${1}">${2]</font>', $text); // [font=arial] I want this text written in arial[/font]		$text = preg_replace('/\[pic=(.+?)\]/i', '<img src="/osi/${1}">', $text); // [pic=Quest_pic_3] On site uploaded images used with the quick access uploader		$text = preg_replace('/\[hide=(.+?)\|(.+?)\](.+?)\[\/hide\]/i', '<a href="javascript://" onClick="t_v(\'${1}\')">${2}</a><br><div id="${1}" style="z-index:1; display:none;">${3}</div>', $text); // [hide=map|Showtext][IMG=url.to.map.png][/hide] to make "Map" a quicklink to expand showing the map, but otherwise hiding the map.		$text = nl2br($text);				return $text;	}