Hello I am attempting to parse a sting with regular expression groups. The final output looks good but has an extra tuple in the list that is empty. How can I fix this. I don't understand why it is happening.
import re
def getRegEx():
regex = '([-+]*)([\d]*)([a-z]*)([=|<=|>=]*)'
return regex
equation_1 = '3x<=6+2y+7z'
pattern = getRegEx()
print(re.findall(pattern, equation_1))
Actual result:
[('', '3', 'x', '<='), ('', '6', '', ''), ('+', '2', 'y', ''), ('+', '7', 'z', ''), ('', '', '', '')]
Expected result:
[('', '3', 'x', '<='), ('', '6', '', ''), ('+', '2', 'y', ''), ('+', '7', 'z', '')]
This question is not similar to a preciously asked question. I have multiple. If I replace any of the current * with plus's I will not get the required output.
*