I'm looking for a regex which match all variables in an expression, which could only be letters followed by a number, like "x1" or not followed by a number, juste like "z". And I want to find them in expressions where they can be followed by all characters, for example
expr = exp(x36)+log(x27)+2*z
For example the regex should return [x36, x27, z]
I have tried this :
pattern = re.findall("[^a-z][a-z][^a-z](\d?)", expr)
where [^a-z][a-z][^a-z] means "not a letter followed by a letter itself followed by not a letter" but it does not seems to work, it returns to me a [] list