From 14ff954f10d88602f501c49206b29ec10e7e4702 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Sun, 7 Jan 2024 23:07:51 +0530 Subject: [PATCH] parse and and print led --- scripts/parse_lb_ls.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 scripts/parse_lb_ls.py diff --git a/scripts/parse_lb_ls.py b/scripts/parse_lb_ls.py new file mode 100644 index 0000000..f7eaba8 --- /dev/null +++ b/scripts/parse_lb_ls.py @@ -0,0 +1,34 @@ +import re + +# Given text +result_text = """ +LB1 23777 +LB2 24130 +LB3 23442 +LB4 23945 +LS1 2521 +LS2 973 +LS3 10252 +LS4 11017 +REND +""" + +# Define a regular expression pattern to extract LB1, LB2, LB3, and LB4 values +pattern = re.compile(r'LB1 (\d+)\s+LB2 (\d+)\s+LB3 (\d+)\s+LB4 (\d+)') + +# Search for the pattern in the text +match = pattern.search(result_text) + +# Extract values if the pattern is found +if match: + lb1_value = match.group(1) + lb2_value = match.group(2) + lb3_value = match.group(3) + lb4_value = match.group(4) + + print("LB1:", lb1_value) + print("LB2:", lb2_value) + print("LB3:", lb3_value) + print("LB4:", lb4_value) +else: + print("Pattern not found.")