<?php
function do_replace($string) {
    $regex = '/^(\((?:<([a-z])>)?(\d{0,3}|[a-z]{1,3})(?:<\/\2>)?(\.)?\)|\[(?:<([a-z])>)?(\d{0,3}|[a-z]{1,3})(?:<\/\2>)?(\.)?\])\s*(.*)/i';
    $result = preg_match($regex, $string);
	if($result) {
		return preg_replace($regex, '%%$1|$8', $string);
	} else {
		$regex = '/^(\d{0,3}|[a-z]{1,3})\.\s*(.+)$/i';
		$result = preg_match($regex, $string);
		if($result) {
			return preg_replace($regex, '%%$1.|$2', $string);
		} else {
			return $string;
		}
	}
}
$strings = array(
	'(1)blahblah',
	'(<i>iv</i>.) blahblah',
	'[b] &nbsp;some stuff',
	'25. blahblah',
	'A. some other stuff. one',
	'blah. some other stuff',
	'text (1) text',
	'2008. blah',
	'[123) <-- mismatch'
);
foreach($strings as $string) echo do_replace($string) . PHP_EOL;
?>