Good day everyone. I just have a question regarding the use of regex in python. If I have a string code that consists of several lines of formula with variable or numeric value.
For example:
code1 = '''
g = -9
h = i + j
year = 2000
month = 0xA
date = 0b1101
sec = 1.8E3
d_1 = year + month
d_2 = date * sec
err = 0o0.1
'''
How would I be able to parse this so that I would get a list of set of strings?
lst = [{Variable}, {numeric value}, {operand}, {None of the above}]
so it would be:
lst = [{g, h, i , j, year, month, date, sec, d_1, d_2, err},{-9,2000,0xA,0b1101,1.8E3},{=, +, *},{0o0.1}]
What I did was just used split() to just separate each string and check if they are an int, or str, or non of the above and it works fine. But I want to know how to do this in regex