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):

\ 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>. >

I believe the problem is the main word limit anchor, but without 2 to X_2

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 (?: -?? \ D +) .

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -