# To support positive/negative integer/float numbers, you could use a slightly modified regexp from http://stackoverflow.com/questions/385558/python-and-regex-question-extract-float-double-value:

import sys
def main():
    import re

    re_float = re.compile("""(?x)
       ^
          [+-]?\ *      # first, match an optional sign *and space*
          (             # then match integers or f.p. mantissas:
              \d+       # start out with a ...
              (
                  \.\d* # mantissa of the form a.b or a.
              )?        # ? takes care of integers of the form a
             |\.\d+     # mantissa of the form .b
          )
          ([eE][+-]?\d+)?  # finally, optionally match an exponent
       """)

    def extract_number(s, default=None):
        m = re_float.match(s)
        if not m:
            return default # no number found
        f = float(m.group(0)) 
        return  int(f) if f.is_integer() else f

### Example

    for s in sys.stdin:
        print(extract_number(s, default=0))

main()        
