src/libs/RomanNumerals.php
public static function romanNumeralMatchCallback($string, $matchMode, callable $callback)
	{

		switch ($matchMode) {
			case 'loose':
			{
				// Note: empty strings are also captured.
				$matchMode = '#\b(M*(?:CM|CD|D?C*)(?:XC|XL|L?X*)(?:IX|IV|V?I*)\b)#i';
				break;
			}
			case 'loose-order':
			{
				$matchMode = '#\b([MDCLXVI]+)\b#i';
				break;
			}
			case 'strict':
			default:
			{
				// Note: empty strings are also captured.
				$matchMode = '#\b(M{0,3}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3})\b)#i';
				break;
			}
		}

		return preg_replace_callback($matchMode, $callback, $string);

	}
public static function romanNumeralMatchCallback($string, $matchMode, callable $callback)
	{

		switch ($matchMode) {
			case 'loose':
			{
				// Note: empty strings are also captured.
				$matchMode = '#\b(M*(?:CM|CD|D?C*)(?:XC|XL|L?X*)(?:IX|IV|V?I*)\b)#i';
				break;
			}
			case 'loose-order':
			{
				$matchMode = '#\b([MDCLXVI]+)\b#i';
				break;
			}
			case 'strict':
			default:
			{
				// Note: empty strings are also captured.
				$matchMode = '#\b(M{0,3}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3})\b)#i';
				break;
			}
		}

		return preg_replace_callback($matchMode, $callback, $string);

	}
@param mixed $string       String to modify
@param string $matchMode   'strict', 'loose' or 'loose-order'
@param callable $callback  Callback that does the manipulation

@return string