I am using python to do some text comparison. The text format is like 44=100.
Let’s say, I have 2 text, 44=100 and 44=3001. I call the string on the left of = is tag, right is value.
Now I need to compare the tag and value for them. The tag must be the same, 44 equals 44, but the values don’t have to, as long as its format is the same. ie. 100 and 3001 are in the same format(normal digits). But 1.0E+7 in 44=1.0E+7 is different.
tThe point is on value comparison. ie. I write a script comp.py, when I run comp.py 2000 30010, I will get output true; while I run comp.py 100000 1.0E+8, output is false. How can I do it? I am thinking about converting the value into an regular expression and comparing it with other.
pseudo code:
rex1 = '100000'.getRegrex(), rex2 = '1.0E+8'.getRegrex(), rex1.compare(rex2)
Is it a feasible way? any advice?
Your approach is wrong. It is not only difficult but also illogical to “deduce” a regexp from a given string. What you would do is: