Extract data from strings based on string formats