<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_language(language):
 """ Attempt to format language parameter as 'ww-WW'. :param string language: language parameter """

    if not language:
        return language

    if not re.match('^[a-zA-Z]{2}[_-][a-zA-Z]{2}$', language):
        raise TwiMLException('Invalid value for language parameter.')

    return language[0:2].lower() + '-' + language[3:5].upper()