import re


def probability_cube_name_regex(cube_name):
    """
    Regular expression matching IMPROVER probability cube name.  Returns
    None if the cube_name does not match the regular expression (ie does
    not start with 'probability_of').

    Args:
        cube_name (str):
            Probability cube name
    """
    regex = re.compile(
        '(probability_of_)'  # always starts this way
        '(?P<diag>.*?)'      # named group for the diagnostic name
        '(_in_vicinity|)'    # optional group, may be empty
        '(?P<thresh>_above_threshold|_below_threshold|_between_thresholds|$)')
    return regex.match(cube_name)