re_float = re.compile(
    """(?x)
   ^
      [+-]?\\ *      
      (             
          \\d+       
          (
              \\.\\d* 
          )?        
         |\\.\\d+     
      )
      ([eE][+-]?\\d+)?  
   $"""
    )
m = re_float.match('4.5')
Extract float/double value