axiacore / py-expression-eval

MIT License
149 stars 54 forks source link

Not all alphanumeric variables possible #70

Open hoonsworld opened 2 years ago

hoonsworld commented 2 years ago

Structural engineers use special alphanumeric variables for principal strains. These are called: e1 and e2 (usually an Epsilon, but an "e" is taken instead). But those alphanumeric variables that start with "e" are not possible with py-expression-eval because it conflicts with the identification of numbers in scientific notation. This is exactly what happens in this line.

There are 2 solutions. The first is quite simple and can be solved with the statement above the line. Here an example:

# Return if Euler's number or if starting with 'e' which could be an alphanumeric variable like e1, e2...
if self.expression[self.pos] == 'E' or self.expression[self.pos] == 'e':
    return False

That would be OK because a scientific number that started with nothing before the "e" wouldn't be a scientific number, and hardly anyone would do that.

The second solution would be to adjust the RE pattern so that at least a single digit number before the "e" is mandatory.

Can you please consider this in the next versions?

Thanks and best regards from Hamburg :)