for a factoring program I’m making I’m wondering if anyone can help me out.
Say I have an equation like
5x^2 + 3x + 7
I need to isolate 5, 3 and 7
although it could come up with negative signs are oppose to positive signs aswell.
Is there any efficient regex that would do it? as the way I’m doing it right now is fairly long and not very efficient.
Try with following regex:
Combine it with
preg_match_allfunction.Explanation:
It matches all digits
with optional negative sign (whitespacesbetween allowed)
that are not followed with
^signor are on the beggining of the string
(so there is
^|[^\^]) matched in non-captured group