import re


def replace_version_string(content, variable, new_version):
    """
    Given the content of a file, finds the version string and updates it.

    :param content: The file contents
    :param variable: The version variable name as a string
    :param new_version: The new version number as a string
    :return: A string with the updated version number
    """
    new_content = re.sub(
        r'({0} ?= ?["\'])\d+\.\d+(?:\.\d+)?(["\'])'.format(variable),
        r'\g<1>{0}\g<2>'.format(new_version),
        content
    )
    # The version string did not chage because above re did not match. Use : instead of =
    if (new_content == content):
        new_content = re.sub(
            r'({0} ?: ?["\'])\d+\.\d+(?:\.\d+)?(["\'])'.format(variable),
            r'\g<1>{0}\g<2>'.format(new_version),
            content
        )
    return new_content