import re


def extract_float_from_string(str):
    """Extract a float from a given string.

    Algorithm from: http://stackoverflow.com/questions/4703390/how-to-extract-a-floating-number-from-a-string-in-python
    Examples:
      - "2" returns 2
      - "3m" returns 3
      - "Current Level: -13.2 db or 14.2 or -3" returns -13.2
    """
    rx = re.compile(r"""
        [-+]? # optional sign
        (?:
            (?: \d* \. \d+ ) # .1 .12 .123 etc 9.1 etc 98.1 etc
            |
            (?: \d+ \.? ) # 1. 12. 123. etc 1 12 123 etc
        )
        # followed by optional exponent part if desired
        (?: [Ee] [+-]? \d+ ) ?
    """, re.VERBOSE)
    floats = rx.findall(str)
    if len(floats) == 0:
        return 0.0
    return float(floats[0])