# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(\d+\s+Timer.*?PHY Status 0x[01]+ - 0x[01].*?tx_p3a_d1en[\s]+0[x\w])+\s+"
test_str = ("000 Timer 0x00000000_0002a465 - 0x00000000_0021453e us: Gen1 - Gen1, DETECT.QUIET - DETECT.QUIET: Status 0x00000030 - 0x00000030: L2R_reason 0x00000000: PHY Status 0x01010000 - 0x01010000\n\n"
" Lane 00:\n\n"
" pga_gain 3, pga_off1 0, pga_off2 1, ph_ofs_t -44,\n\n"
" cdfe_a2 52, cdfe_a3 64, cdfe_a4 118, cdfe_a5 71, cdfe_a6 12, cdfe_a7 124, cdfe_a8 24, cdfe_a9 76, cdfe_a10 49,\n\n"
" zobel_a_gain 12, zobel_b_gain 0, zobel_dc_ofs 260, dc_ofs 25, udfe_thr_0 -152, udfe_thr_1 14, median_amp 179,\n\n"
" cdru_lock_count 0, eh_workaround_stat 0x0, los_toggle_cnt 0x8000, adapt_time 207872, cdr_lock_toggle_cnt 0x3000, jat_stat 0x804d\n\n"
" fs_obs 0, lf_obs 0, pre_cursor 0, cursor 0, post_cursor 0, usp_tx_preset 0x0, dsp_tx_preset 0x0\n\n"
" tx_p1a_d1en 0x30, tx_p1a_d2en 0xf, tx_p1a_amp_red 0x0, tx_p1b_d1en 0x3f, tx_p1b_d2en 0x0, tx_p1b_amp_red 0x0\n\n"
" tx_p2a_d1en 0x3f, tx_p2a_d2en 0x0, tx_p2a_amp_red 0x0, tx_p2b_d1en 0x3f, tx_p2b_d2en 0x0, tx_p2b_amp_red 0x0 tx_p3a_d1en 0x28\n\n"
" Lane 01:\n\n"
" pga_gain 15, pga_off1 24, pga_off2 6, ph_ofs_t -57,\n\n"
" cdfe_a2 -106, cdfe_a3 120, cdfe_a4 -80, cdfe_a5 -31, cdfe_a6 -13, cdfe_a7 127, cdfe_a8 96, cdfe_a9 127, cdfe_a10 4,\n\n"
" zobel_a_gain 0, zobel_b_gain 0, zobel_dc_ofs 457, dc_ofs 217, udfe_thr_0 -215, udfe_thr_1 219, median_amp 176,\n\n"
" cdru_lock_count 0, eh_workaround_stat 0x0, los_toggle_cnt 0x8000, adapt_time 207872, cdr_lock_toggle_cnt 0x3000, jat_stat 0x804d\n\n"
" fs_obs 0, lf_obs 0, pre_cursor 0, cursor 0, post_cursor 0, usp_tx_preset 0x0, dsp_tx_preset 0x0\n\n"
" tx_p1a_d1en 0x30, tx_p1a_d2en 0xf, tx_p1a_amp_red 0x0, tx_p1b_d1en 0x3f, tx_p1b_d2en 0x0, tx_p1b_amp_red 0x0\n\n"
" tx_p2a_d1en 0x3f, tx_p2a_d2en 0x0, tx_p2a_amp_red 0x0, tx_p2b_d1en 0x3f, tx_p2b_d2en 0x0, tx_p2b_amp_red 0x0 tx_p3a_d1en 0x28\n\n")
matches = re.search(regex, test_str)
if matches:
print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html