# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^UVM_[A-Z]*|build.+?(?=\()|[0-9]+(?=\))|(?<=@ )[0-9]+|(?<= \[).*?(?=\]\s)|(?<=: ).*?(?= \[)|((?<=\]).*())"
test_str = ("UVM_INFO build/vcs-rtl-default-queue/sbu_tb/sv/SbuSbMonitor/bmiTransRecorder.sv(495) @ 4725749: reporter@@BMI_TXN [BMI_RECORDER] @ 4725749 [BMI ID: 95] bmiDone=0 nbuId=0xa biuId=0x0 devRst=0 m_error=0 type=write_data snpId=0x5 txnId=0x1c124 devTag=0x0 wrIdx=0x0 addr=0x300ac len=0x4 space=3 dev_cmd=unknown data=0x25c20d74288413f2387891d50000000000000119ec331542f7518539c4101a2d7a0ccdbfd7837f2f918651f3dda1de0c54fb652228b2c1ced2ae6bd16dd302dd lv=0x0\n"
"UVM_INFO build/vcs-test_bmi_rsp-default-queue/sbu_tb/sv/SmmuModel/tlb_cache.sv(130) @ 264291: tlb_cache_h [tlb_cache] TLB_CACHE:: BEFORE pagesize[ 310][ 0] = 0 AFTER - pagesize[ 310][ 0] = 1\n")
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.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