Regular Expressions 101

Matching and Grouping Second Degree Polynomials

Open Workspace
  • PCRE2 (PHP)
  • Match
0

Regular Expression

/
^(?:([-]?\d*)[x](?:\^2))(?:(?:\+(\d*)[x])?|(?:(\-\d*)[x])?)(?:(?:\+([\d]))?|(?:(\-[\d]))?)(?:(\=)|)(?:(0)|)$
/

Description

Matches second-degree polynomials and returns values a, b, c, sign, and 0.

Submitted by SpiderRocket