(appversion_text)
>>> # these first two could certainly be replaced
    >>> # with more realistic examples, but I didn't have any on hand
    >>> get_version_from_appversion_text('foofoo #102 barbar')
    102
    >>> get_version_from_appversion_text('foofoo b[99] barbar')
    99
    >>> get_version_from_appversion_text(
    ...     'CommCare ODK, version "2.11.0"(29272). App v65. '
    ...     'CommCare Version 2.11. Build 29272, built on: February-14-2014'
    ... )
    65
    >>> get_version_from_appversion_text(
    ...     'CommCare ODK, version "2.4.1"(10083). App v19.'
    ...     'CommCare Version 2.4. Build 10083, built on: March-12-2013'
    ... )
    19
>>> # these first two could certainly be replaced
    >>> # with more realistic examples, but I didn't have any on hand
    >>> get_version_from_appversion_text('foofoo #102 barbar')
    102
    >>> get_version_from_appversion_text('foofoo b[99] barbar')
    99
    >>> get_version_from_appversion_text(
    ...     'CommCare ODK, version "2.11.0"(29272). App v65. '
    ...     'CommCare Version 2.11. Build 29272, built on: February-14-2014'
    ... )
    65
    >>> get_version_from_appversion_text(
    ...     'CommCare ODK, version "2.4.1"(10083). App v19.'
    ...     'CommCare Version 2.4. Build 10083, built on: March-12-2013'
    ... )
    19
>>> # these first two could certainly be replaced >>> # with more realistic examples but I didn t have any on hand >>> get_version_from_appversion_text ( foofoo #102 barbar ) 102 >>> get_version_from_appversion_text ( foofoo b [ 99 ] barbar ) 99 >>> get_version_from_appversion_text ( ... CommCare ODK version 2 . 11 . 0 ( 29272 ) . App v65 . ... CommCare Version 2 . 11 . Build 29272 built on : February - 14 - 2014 ... ) 65 >>> get_version_from_appversion_text ( ... CommCare ODK version 2 . 4 . 1 ( 10083 ) . App v19 . ... CommCare Version 2 . 4 . Build 10083 built on : March - 12 - 2013 ... ) 19
def get_version_from_appversion_text(appversion_text):
    """
    >>> # these first two could certainly be replaced
    >>> # with more realistic examples, but I didn't have any on hand
    >>> get_version_from_appversion_text('foofoo #102 barbar')
    102
    >>> get_version_from_appversion_text('foofoo b[99] barbar')
    99
    >>> get_version_from_appversion_text(
    ...     'CommCare ODK, version "2.11.0"(29272). App v65. '
    ...     'CommCare Version 2.11. Build 29272, built on: February-14-2014'
    ... )
    65
    >>> get_version_from_appversion_text(
    ...     'CommCare ODK, version "2.4.1"(10083). App v19.'
    ...     'CommCare Version 2.4. Build 10083, built on: March-12-2013'
    ... )
    19
    """
    patterns = [
        r' #(\d+) ',
        r'b\[(\d+)\]',
        r'App v(\d+).',
    ]
    version_string = _first_group_match(appversion_text, patterns)
    if version_string:
        return int(version_string)
def get_version_from_appversion_text ( appversion_text ) : patterns = [ r' #(\d+) ' , r'b\[(\d+)\]' , r'App v(\d+).' , ] version_string = _first_group_match ( appversion_text , patterns ) if version_string : return int ( version_string )