Extract the Coefficients of a Linear Equation Given a linear equation mx+n, return n and m. However, the equation may be in any of the following formats:

5x+2 -&gt; 5 2
5x-2 -&gt; 5 -2
5x   -&gt; 5 0
-2   -&gt; 0 -2
x    -&gt; 1 0


Here are the formats, where each ? stands for a positive integer written without leading zeroes

?x+?
?x-?
-?x+?
-?x-?
x+?
x-?
?
-?
?x
-?x
x


All of these cases must be handled.

Specifications:


You can assume that the equation is in one of the above formats, i.e. it matches the regex ^(-?[123456789]\d*)?x([+-][123456789]\d*)?|-?[123456789]\d*$.


Test Cases:

-2x+3 -&gt; -2 3
44x   -&gt; 44 0
-123  -&gt; 0 -123
x     -&gt; 1 0
-1x   -&gt; -1 0
Python 2, 55 bytes



j=1j
c=eval(input().replace(*'xj'))
print c.imag,c.real


Try it online!

Uses Python's built-in code evaluation. The input is formatted like a complex number by replacing x withj, Python's complex unit. Because only literals like 2j are recognized, but not j or -j, the variable j is assigned as 1j to cover those.

Unfortunately, Python doesn't seem to have a built-in to convert a complex number to a pair of reals.