import re
regex = re.compile(r"procs=(\d+);\S+")
test_str = "DATATYPE::SERVICEPERFDATA TIMET::1519222690 HOSTNAME::localhost SERVICEDESC::Total Processes SERVICEPERFDATA::procs=59;250;400;0; SERVICECHECKCOMMAND::check_local_procs!250!400!RSZDT HOSTSTATE::UP HOSTSTATETYPE::HARD SERVICESTATE::OK SERVICESTATETYPE::HARD"
subst = "$1"
result = regex.sub(subst, test_str)
if result:
print(result)
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