fork download
  1. import re
  2.  
  3. def getGUIDS(old_string):
  4. '''
  5. Finds guids in the string and formats it as PK for syncfile
  6. @param old_string the string created from the nested dict
  7. @return old_string_fmt the formatted version
  8. '''
  9. print ('getting ids')
  10. return re.sub(r'"\w+"="(\w{8}(?:-\w{4}){4}-\w{12})"(?:,|$)', '\\1\t', old_string) #looks for GUID based on regex
  11.  
  12. s='"visitorid"="gh43k9sk-gj49-92ks-jgjs-j2ks-j29slgj952ks", "customer_name"="larry", "customer_state"="alabama",..."visitorid"="..."'
  13. print(getGUIDS(s))
  14.  
Success #stdin #stdout 0.02s 6888KB
stdin
Standard input is empty
stdout
getting ids
gh43k9sk-gj49-92ks-jgjs-j2ks-j29slgj952ks	 "customer_name"="larry", "customer_state"="alabama",..."visitorid"="..."