Created
November 23, 2012 01:24
-
-
Save widoyo/4133590 to your computer and use it in GitHub Desktop.
Baca Email RMR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import re | |
>>> # mencari RMR Number pada Subject email | |
>>> "Re: RMR Number 121127-I01-07-1".rsplit(" ", 1)[1] | |
121127-I01-07-1 | |
>>> inputs = ["Re: RMR Number 121127-I01-07-1", "RMR Number 121127-I01-07-1", "Re: RMR NUmber 121127-I08-PP-1"] | |
>>> | |
>>> for a in inputs: | |
... m = re.match(r'.*RMR Number.*(?P<rmr>\d{6}-\w{1}\d{2}-.*-\d{1})', a, re.I) | |
... if m: | |
... m.groupdict()['rmr'] | |
... | |
'121127-I01-07-1' | |
'121127-I01-07-1' | |
'121127-I08-PP-1' | |
>>> | |
>>> samples_ack = ('> Acknoledgement\t\t: OK', | |
... '> Acknoledgement\t\t: Ok', | |
... '> Acknoledgement\t\t: .Ok', | |
... '> Acknoledgement\t\t: . Ok', | |
... '> Acknoledgement:Ok', | |
... 'Acknoledgement : Ok', | |
... ) | |
>>> | |
>>> for ack in samples_ack: | |
... if not re.search('Acknoledgement.*:.*ok', ack, re.I): | |
... print "GAGAL: %s" % ack | |
... else: | |
... print "LULUS: %s" % ack | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment