regex - Minus sign breaking equation extraction -
I am trying to create a regular expression that removes the numerical constant and operator from an equation.
X_1 + 1234 * 5678 + 2 (where X_1
is not static, so it has been ignored) , I 1234 * 5678 + 2
.
I have a regular expression that works for the above case, but it breaks when the first number is negative.
Here's my current regular expression (spaces for clarity):
I believe the problem is the main word limit anchor, but without Edit: For the sake of simplicity, there is a "variable" which is not always a numeric. A "numerical constant" is a Positive or negative integer value. In my above expression, they match \ b ((?::??? D +) (?: \ S * [\ * \ +] (?: -?) However, if the numeric constant is negative, then the zero mark is omitted. For example, with an input,
X_2 * - 128 + 18 * 3,
, 128
code>. > 2
to X_2
(?: -?? \ D +)
.
Comments
Post a Comment