I have a character list in this format "EXECUTE SYS-SM-THIS-1004"
What's the efficient way to split this list based on the conditions:
- From the list, consider the characters after EXECUTE, split them using hyphen(-) as delimiter
- From the resulting list, first element must be equal to any one of [SYS, CSC, ISC]
- Last word must be a 4 digit number
- Contents between first and last words to be moved into a new list after removing the Leading and ending hyphens. Finally hyphen to be replaced with underscore.
Condition to find if the line has the work EXECUTE is working. How to check the other conditions?
if re.match('^\s*EXECUTE .*', line) or re.match('^\s*execute.*', line) :
Input:
a = ["EXECUTE SYS-SM-THIS-1004"]
Expected Output:
X = SYS
Y = SM_THIS
Z = SYS-SM-THIS-1004
re.IorIGNORECASEflag fot that.