import typing
import re


def orbital_pattern(compile: bool = True) -> typing.Union[typing.Pattern[str], str]:
	"""
	Creates a regex pattern for recognizing orbital strings.

	Parameters
	----------
		compile : bool
			If true the regex is compiled, otherwise it is returned as a string.

	Returns
	----------
	Returns a compiled pattern or string depending on the compile parameter.
	"""
	regex_string = r"([A-Q]\d( \d+)+)"
	if compile:
		return re.compile(regex_string)
	return regex_string