import re


def get_device_id_from_body(body):
    """Extracts the device ID from the given body.
    
    Arguments:
        body {dict} -- The body as extracted by `extract_body()`
    
    Returns:
        str -- The device ID if given. If there's an error extracting this
               or if the id is malformed, None is returned.
    """
    if 'device_id' in body:
        device_id = body['device_id']
        if re.match("^[a-zA-Z0-9]{3,4}-[a-zA-Z0-9]{3,4}-[a-zA-Z0-9]{4}$", device_id):
            return device_id
    return None