Skip to content
Advertisement

Tag: polynomials

Regex for polynomial expression

I have a string that I hope is a polynomial expression, something like “2x^2-3x+1. I want to use a regex to group each term in the expression. I currently have “^(-?d?x(^d)?)+”. I’m trying to capture a term as an optional minus sign, then a number, then x, then an optional exponent, which should be of the form “^someNumber”. So for

Advertisement