fork(1) download
  1. import re
  2.  
  3. regex = r"((?:Second)?)Latitude:(-?\d+(?:\.\d+)?)\1Longitude:(-?\d+(?:\.\d+)?)"
  4. s = ("WorkLocationBoundingBox\n"
  5. "Latitude:30.556555Longitude:-97.659824\n"
  6. "SecondLatitude:30.569138SecondLongitude:-97.650855")
  7.  
  8. matches = re.finditer(regex, s)
  9. lst = []
  10.  
  11. for matchNum, match in enumerate(matches, start=1):
  12. lst.append(match.group(2))
  13. lst.append(match.group(3))
  14.  
  15. print(lst)
Success #stdin #stdout 0.02s 9708KB
stdin
Standard input is empty
stdout
['30.556555', '-97.659824', '30.569138', '-97.650855']