Created
April 26, 2012 00:18
-
-
Save memee/2494709 to your computer and use it in GitHub Desktop.
regexp
This file contains hidden or 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
>>> resp = """Serial number:<br/> | |
... 353511021287981<br/> | |
... Warranty:<br/> | |
... NO <br/>""" | |
>>> import re | |
>>> patt = re.compile(r'([^>\r]+):.?<br/>.?([^<]+)', re.DOTALL) | |
>>> match = patt.search(resp) | |
>>> match | |
<_sre.SRE_Match object at 0x10535bb58> | |
>>> match.groups(0) | |
('Serial number', '353511021287981') | |
>>> match.groups(1) | |
('Serial number', '353511021287981') | |
>>> match.groups(2) | |
('Serial number', '353511021287981') | |
>>> |
romanbarczynski
commented
Apr 26, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment