Advertisement
Guest User

Untitled

a guest
Apr 24th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import re
  4. import sys
  5.  
  6. for line in sys.stdin:
  7. line = line.lower();
  8. line = "".join(re.split('checkcard\s[0-9]{4}',line))
  9. cost_re=re.search('(?<=-)?[0-9]*\.[0-9]{2}(?<=-)?',line)
  10. line = line.replace("&","and")
  11. name_re=re.search('([a-zA-Z]+[\*\-\&\']?\w* ?){1,3}',line)
  12.  
  13.  
  14. if cost_re is not None and name_re is not None:
  15. cost=float(cost_re.group(0))
  16. name=name_re.group(0)
  17. print "%s\t%f" % (name.upper(), cost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement