python parsing suggestion
Jason Friedman
jsf80238 at gmail.com
Mon May 30 11:00:34 EDT 2016
>
> Trying to extract the '1,1,114688:8192' pattern form the below output.
>
> pdb>stdout:
> '3aae5d0-1: Parent Block for 1,1,19169280:8192 (block 1,1,114688:8192)
> --\n3aae5d0-1:
> magic 0xdeaff2fe mark_cookie
> 0x0000000000000000\ngpal-3aae5d0-1: super.status
> 3 super.cookie 390781895\ngpal-3aae5d0-1:
> cg_xth 0
>
A regular expression solution:
import re
s = """3aae5d0-1: Parent Block for 1,1,19169280:8192 (block 1,1,114688:8192)
--\n3aae5d0-1:
magic 0xdeaff2fe mark_cookie
0x0000000000000000\ngpal-3aae5d0-1: super.status
3 super.cookie 390781895\ngpal-3aae5d0-1:
cg_xth 0"""
pattern = re.compile(r"""
\( # open paren
block
\s # whitespace
( # start capture
\d
,
\d
,
\d+
:
\d+
) # end capture
""", re.VERBOSE | re.MULTILINE)
match = re.search(pattern, s)
print(match.group(1))
More information about the Python-list
mailing list